結果

問題 No.3340 Simple Graph Game
コンテスト
ユーザー GGanari
提出日時 2025-11-19 21:43:27
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,331 bytes
コンパイル時間 2,207 ms
コンパイル使用メモリ 201,360 KB
実行使用メモリ 25,272 KB
最終ジャッジ日時 2025-11-19 21:43:34
合計ジャッジ時間 6,571 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#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];
vector<int> graph2[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);
    vector<int> cnt(n+1);
    for(int i = 1; i<=n; i++)
    {
        int a,b;
        cin >> a >> b;
        graph[b].push_back(a);
        graph2[a].push_back(b);
        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])
        {
            degree[y]--;
            if(res[y] != 2)
                continue;
            if(res[x] == 0)
            {
                res[y] = 1;
                q.push(y);
            }
            else if(degree[y] == 0)
            {
                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;
}
0