結果

問題 No.3340 Simple Graph Game
コンテスト
ユーザー GOTKAKO
提出日時 2025-11-13 21:40:03
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 955 bytes
コンパイル時間 2,168 ms
コンパイル使用メモリ 205,228 KB
実行使用メモリ 21,852 KB
最終ジャッジ日時 2025-11-13 21:40:14
合計ジャッジ時間 5,934 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N,M; cin >> N >> M;
    vector<vector<int>> Graph(N),rev(N);
    for(int i=0; i<M; i++){
        int u,v; cin >> u >> v;
        u--; v--;
        Graph.at(u).push_back(v);
        rev.at(v).push_back(u);
    }
    vector<int> V(N);
    vector<bool> already(N);
    queue<int> Q;
    for(int i=0; i<N; i++){
        V.at(i) = Graph.at(i).size();
        if(V.at(i) == 0) already.at(i) = true,Q.push(i);
    }
    vector<int> win(N);
    while(Q.size()){
        int pos = Q.front(); Q.pop();
        if(!win.at(pos)){
            for(auto to : rev.at(pos)) win.at(to) = 1,Q.push(to);
        }
        else{
            for(auto to : rev.at(pos)) if(--V.at(to) == 0) win.at(to) = -1,Q.push(to);
        }
    }
    if(win.at(0) == 1) cout << "Alice\n";
    else if(win.at(0) == -1) cout << "Bob\n";
    else cout << "Draw\n";
}
0