結果
| 問題 |
No.3340 Simple Graph Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-13 23:11:49 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 97 ms / 2,000 ms |
| コード長 | 1,162 bytes |
| コンパイル時間 | 3,971 ms |
| コンパイル使用メモリ | 255,724 KB |
| 実行使用メモリ | 22,416 KB |
| 最終ジャッジ日時 | 2025-11-18 10:39:14 |
| 合計ジャッジ時間 | 7,340 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 59 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)
#define all(x) begin(x), end(x)
template <class T> bool chmin(T& x, T y) {
return x > y ? (x = y, true) : false;
}
template <class T> bool chmax(T& x, T y) {
return x < y ? (x = y, true) : false;
}
struct io_setup {
io_setup() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(15);
}
} io_setup;
void solve() {
int n, m;
cin >> n >> m;
vector<vector<int>> g(n);
rep(i, 0, m) {
int u, v;
cin >> u >> v;
u--, v--;
g[u].push_back(v);
}
vector mm(n, vector<int>(2, -1));
auto dfs = [&](auto self, int nw, int p) -> int {
if (mm[nw][p] != -1) return mm[nw][p];
mm[nw][p] = 2;
int flg = 0;
for (int nx : g[nw]) {
int tmp = self(self, nx, p ^ 1);
if (tmp == 1) continue;
if (tmp == 0) {
flg = 1;
break;
}
flg = 2;
}
return mm[nw][p] = flg;
};
int res = dfs(dfs, 0, 0);
if (res == 0) cout << "Bob\n";
else if (res == 1) cout << "Alice\n";
else cout << "Draw\n";
}
int main() {
int t = 1;
// cin >> t;
while (t--) solve();
}