結果
| 問題 |
No.3340 Simple Graph Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-19 21:27:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,458 bytes |
| コンパイル時間 | 2,135 ms |
| コンパイル使用メモリ | 201,104 KB |
| 実行使用メモリ | 16,156 KB |
| 最終ジャッジ日時 | 2025-11-19 21:28:06 |
| 合計ジャッジ時間 | 6,306 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 WA * 23 |
ソースコード
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define long long long
#define INF 1000000001
#define LNF 10000000011000000001
using namespace std;
vector<int> graph[200001];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,m;
cin >> n >> m;
vector<int> res(n+1,2);
vector<int> degree(n+1);
for(int i = 1; i<=n; i++)
{
int a,b;
cin >> a >> b;
graph[b].push_back(a);
degree[a]++;
}
queue<int> q;
for(int i = 1; i<=n; i++)
{
if(degree[i] == 0)
{
res[i] = 0;
q.push(i);
}
}
while(!q.empty())
{
int x = q.front();
q.pop();
for(int y : graph[x])
{
if(res[y] != 2)
continue;
if(res[x] == 0)
{
res[y] = 1;
q.push(y);
}
else
{
bool isTrue = true;
for(int z : graph[y])
{
if(res[z] != 1)
isTrue = false;
}
if(isTrue)
{
res[y] = 0;
q.push(y);
}
}
}
}
if(res[1] == 0)
cout << "Bob" << endl;
if(res[1] == 1)
cout << "Alice" << endl;
if(res[1] == 2)
cout << "Draw" << endl;
return 0;
}