結果
| 問題 |
No.2664 Prime Sum
|
| コンテスト | |
| ユーザー |
れいん
|
| 提出日時 | 2024-12-09 15:54:17 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 966 bytes |
| コンパイル時間 | 5,438 ms |
| コンパイル使用メモリ | 310,508 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-09 15:54:25 |
| 合計ジャッジ時間 | 6,942 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 37 |
ソースコード
#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)
{
P[nv] = self ^ 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";
}
}
れいん