結果
問題 | No.488 四角関係 |
ユーザー |
|
提出日時 | 2020-04-15 21:47:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 486 ms / 5,000 ms |
コード長 | 1,063 bytes |
コンパイル時間 | 1,306 ms |
コンパイル使用メモリ | 77,804 KB |
最終ジャッジ日時 | 2025-01-09 19:19:54 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <iostream> #include <vector> template <class T> std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); } void solve() { int n; std::cin >> n; auto graph = vec(n, vec(n, false)); int m; std::cin >> m; while (m--) { int u, v; std::cin >> u >> v; graph[u][v] = graph[v][u] = true; } int ans = 0; for (int b = 0; b < n * n * n * n; ++b) { std::vector<int> vs(4); { int nb = b; for (int i = 0; i < 4; ++i) { vs[i] = nb % n; nb /= n; } } bool valid = true; for (int j = 0; j < 4; ++j) { for (int i = 0; i < j; ++i) { if (vs[i] == vs[j]) valid = false; if (((i - j) % 2 == 0) == (graph[vs[i]][vs[j]])) valid = false; } } if (valid) ++ans; } std::cout << ans / 8 << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }