結果

問題 No.3340 Simple Graph Game
コンテスト
ユーザー kotatsugame
提出日時 2025-11-13 22:51:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 582 bytes
コンパイル時間 690 ms
コンパイル使用メモリ 69,408 KB
実行使用メモリ 14,180 KB
最終ジャッジ日時 2025-11-18 10:39:06
合計ジャッジ時間 4,220 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 59
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<cassert>
using namespace std;
int N,M;
vector<int>G[2<<17];
int vis[2<<17];
int dfs(int u)
{
	if(vis[u]!=0)return vis[u];
	vis[u]=-1;
	bool draw=false,win=false;
	for(int v:G[u])
	{
		int t=dfs(v);
		if(t==1);
		else if(t==2)win=true;
		else draw=true;
	}
	vis[u]=win?1:draw?-1:2;
	return vis[u];
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>N>>M;
	for(int i=0;i<M;i++)
	{
		int u,v;cin>>u>>v;u--,v--;
		G[u].push_back(v);
		//G[v].push_back(u);
	}
	int t=dfs(0);
	cout<<(t==1?"Alice":t==2?"Bob":"Draw")<<endl;
}
0