Submission #21268298
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5+10;
int n;
int head[maxn], nxt[maxn], to[maxn], tot = 1;
int vis[maxn];
void add(int x, int y) {
++tot;
nxt[tot] = head[x];
to[tot] = y;
head[x] = tot;
}
int dfs(int x) {
vis[x] = 1;
int ret = 0;
for (int e = head[x]; e; e = nxt[e]) {
int y = to[e];
if (vis[y]) continue;
ret ^= dfs(y)+1;
}
return ret;
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n-1; ++i) {
int x, y;
scanf("%d%d", &x, &y);
add(x,y), add(y,x);
}
if (dfs(1)) puts("Alice");
else puts("Bob");
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Game on Tree |
| User | frank3215 |
| Language | C++ (GCC 9.2.1) |
| Score | 1100 |
| Code Size | 604 Byte |
| Status | AC |
| Exec Time | 41 ms |
| Memory | 10792 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:30:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
30 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
./Main.cpp:33:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
33 | scanf("%d%d", &x, &y);
| ~~~~~^~~~~~~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 1100 / 1100 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample1.txt, sample2.txt, sample3.txt, sample4.txt |
| All | sample1.txt, sample2.txt, sample3.txt, sample4.txt, a1.txt, a10.txt, a11.txt, a12.txt, a13.txt, a14.txt, a15.txt, a16.txt, a17.txt, a18.txt, a19.txt, a2.txt, a20.txt, a21.txt, a22.txt, a23.txt, a24.txt, a25.txt, a26.txt, a27.txt, a28.txt, a29.txt, a3.txt, a30.txt, a4.txt, a5.txt, a6.txt, a7.txt, a8.txt, a9.txt, b1.txt, b2.txt, b3.txt, b4.txt, b5.txt, sample1.txt, sample2.txt, sample3.txt, sample4.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| a1.txt | AC | 8 ms | 3688 KiB |
| a10.txt | AC | 5 ms | 4028 KiB |
| a11.txt | AC | 6 ms | 3976 KiB |
| a12.txt | AC | 6 ms | 3852 KiB |
| a13.txt | AC | 33 ms | 5996 KiB |
| a14.txt | AC | 34 ms | 5992 KiB |
| a15.txt | AC | 29 ms | 5408 KiB |
| a16.txt | AC | 33 ms | 6228 KiB |
| a17.txt | AC | 36 ms | 6204 KiB |
| a18.txt | AC | 34 ms | 6120 KiB |
| a19.txt | AC | 40 ms | 7000 KiB |
| a2.txt | AC | 4 ms | 3680 KiB |
| a20.txt | AC | 38 ms | 7052 KiB |
| a21.txt | AC | 36 ms | 6504 KiB |
| a22.txt | AC | 34 ms | 6024 KiB |
| a23.txt | AC | 34 ms | 5864 KiB |
| a24.txt | AC | 29 ms | 5520 KiB |
| a25.txt | AC | 32 ms | 6200 KiB |
| a26.txt | AC | 35 ms | 6208 KiB |
| a27.txt | AC | 35 ms | 6208 KiB |
| a28.txt | AC | 33 ms | 7020 KiB |
| a29.txt | AC | 40 ms | 7008 KiB |
| a3.txt | AC | 9 ms | 3748 KiB |
| a30.txt | AC | 28 ms | 6496 KiB |
| a4.txt | AC | 10 ms | 3900 KiB |
| a5.txt | AC | 9 ms | 4004 KiB |
| a6.txt | AC | 6 ms | 3736 KiB |
| a7.txt | AC | 6 ms | 3884 KiB |
| a8.txt | AC | 9 ms | 3884 KiB |
| a9.txt | AC | 7 ms | 3880 KiB |
| b1.txt | AC | 41 ms | 10536 KiB |
| b2.txt | AC | 40 ms | 8200 KiB |
| b3.txt | AC | 38 ms | 10792 KiB |
| b4.txt | AC | 39 ms | 8320 KiB |
| b5.txt | AC | 38 ms | 8316 KiB |
| sample1.txt | AC | 4 ms | 3688 KiB |
| sample2.txt | AC | 3 ms | 3508 KiB |
| sample3.txt | AC | 2 ms | 3516 KiB |
| sample4.txt | AC | 2 ms | 3776 KiB |