結果
問題 | No.2664 Prime Sum |
ユーザー |
![]() |
提出日時 | 2024-12-09 15:54:49 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 932 bytes |
コンパイル時間 | 5,843 ms |
コンパイル使用メモリ | 309,252 KB |
実行使用メモリ | 818,176 KB |
最終ジャッジ日時 | 2024-12-09 15:55:52 |
合計ジャッジ時間 | 60,610 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 1 MLE * 36 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; int main() { int N, M; cin >> N >> M; vector<vector<int>> G(N); for (int i = 0; i < M; i++) { int A, B; cin >> A >> B; A--; B--; G[A].push_back(B); G[B].push_back(A); } vector<int> P(N, -1); bool ok = true; auto dfs = [&](auto dfs, int v, int p) -> void { P[v] = p; int self = P[v]; for (auto nv : G[v]) { if (P[nv] == -1) { dfs(dfs, nv, P[nv]); } else if (self == P[nv]) { ok = false; } } }; for (int i = 0; i < N; i++) { if (P[i] == -1) { dfs(dfs, i, 0); } } if (ok) { cout << "Yes"; } else { cout << "No"; } }