結果
問題 | No.2664 Prime Sum |
ユーザー |
![]() |
提出日時 | 2025-05-27 00:03:35 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 975 bytes |
コンパイル時間 | 2,785 ms |
コンパイル使用メモリ | 284,424 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-05-27 00:03:40 |
合計ジャッジ時間 | 4,171 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 37 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, m; cin >> n >> m; vector Graph(n, vector<int>(0)); rep(_, m) { int u, v; cin >> u >> v; --u; --v; Graph[u].push_back(v); Graph[v].push_back(u); } vector<int> col(n, -1); bool is_bipartite = true; rep(i, n) { if (col[i] != -1) continue; queue<int> q; q.push(i); col[i] = 0; while (!q.empty()) { int u = q.front(); q.pop(); for (int v : Graph[u]) { if (col[v] == -1) { col[v] = 1 - col[u]; q.push(v); } else if (col[v] == col[u]) { is_bipartite = false; } } } } cout << (is_bipartite ? "Yes" : "No") << '\n'; return 0; }