QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#397873#4549. Alice和Bob又在玩游戏xuzishuai0 75ms7472kbC++141.5kb2024-04-24 18:52:592024-04-24 18:53:03

Judging History

你现在查看的是最新测评结果

  • [2024-04-24 18:53:03]
  • 评测
  • 测评结果:0
  • 用时:75ms
  • 内存:7472kb
  • [2024-04-24 18:52:59]
  • 提交

answer

#include<bits/stdc++.h>
#define fq(i,d,u) for(int i(d); i<=u; ++i)
#define fr(i,u,d) for(int i(u); i>=d; --i)
#define sf scanf
#define pf printf
using namespace std;
const int N = 1e5 + 5;

int n,m;
vector<int> tr[N];
int fa[N],siz[N];

int sg[N];
bool vis[N],del[N];
list <int> st;
int tmp[N],cnt;

void get(int p){
    // cout << p <<"&\n";
    st.push_back(p); del[p] = 1;

    for(auto to : tr[p]){
        if(to == fa[p]) continue;
        get(to);
    }

    if(st.size() != siz[st.front()]) ++cnt;
    for(auto x : st)
        for(auto to : tr[x])
        if(to != fa[x] && !del[to]) tmp[cnt] ^= sg[to];

    del[st.back()] = 0;
    st.pop_back();
}
void dfs1(int x,int f){
    siz[x] = vis[x] = 1; fa[x] = f;
    for(auto to : tr[x]) {
        if(to == f) continue;
        dfs1(to,x);
        siz[x] += siz[to];
    }

    cnt = 0;
    get(x);
    sort(tmp + 1,tmp + 1 + n);
    fq(i,1,cnt) {if(sg[x] < tmp[i]) break; sg[x] = tmp[i] + 1;}
}
void solve(){
    cin >> n >> m;
    fq(i,1,m) {
        int u,v; cin >> u >> v;
        tr[u].push_back(v);
        tr[v].push_back(u);
    }

    int ans(0);
    fq(i,1,n) if(!vis[i]) {dfs1(i,i); ans ^= sg[i];}
    // fq(i,1,n) pf("%d ",sg[i]); pf("#\n");

    if(!ans) pf("Bob\n");
    else pf("Alice\n");

    fq(i,1,n) {tr[i].clear(); siz[i] = vis[i] = 0; sg[i] = 0;}
}
int main(){

    // memset(sg,-1,sizeof(sg));
    int T; cin >> T;
    while(T--) {solve();}

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 7392kb

input:

6
3 0
5 0
7 0
4 0
6 0
8 0

output:

Bob
Bob
Bob
Bob
Bob
Bob

result:

wrong answer 1st lines differ - expected: 'Alice', found: 'Bob'

Test #2:

score: 0
Wrong Answer
time: 1ms
memory: 6908kb

input:

6
13 0
15 0
7 0
14 0
16 0
18 0

output:

Bob
Bob
Bob
Bob
Bob
Bob

result:

wrong answer 1st lines differ - expected: 'Alice', found: 'Bob'

Test #3:

score: 0
Wrong Answer
time: 1ms
memory: 7472kb

input:

10
20 15
6 11
1 12
12 6
2 12
18 7
3 16
10 9
10 12
19 17
10 15
19 7
14 15
7 20
18 10
3 12
20 17
3 7
1 12
8 16
20 2
16 15
18 11
1 16
19 6
13 14
19 9
1 5
18 4
14 20
9 16
17 19
7 16
20 10
20 18
1 7
4 19
14 6
14 1
11 17
3 19
9 18
20 2
12 1
8 1
17 15
16 13
13 5
10 1
20 9
17 13
5 3
8 18
20 19
15 10
2 6
1 4...

output:

Alice
Alice
Bob
Alice
Alice
Alice
Alice
Alice
Alice
Alice

result:

wrong answer 2nd lines differ - expected: 'Bob', found: 'Alice'

Test #4:

score: 0
Wrong Answer
time: 1ms
memory: 7160kb

input:

10
20 17
11 7
8 2
13 6
1 8
10 8
11 4
19 12
18 16
15 14
20 17
13 9
12 9
15 10
12 2
9 16
3 16
7 15
20 17
20 12
7 1
7 3
12 13
1 5
9 18
18 5
17 5
16 11
12 11
10 5
8 2
4 12
14 12
6 11
11 1
15 5
20 18
12 15
13 19
8 9
7 12
8 1
5 8
19 6
16 12
12 18
8 3
5 19
17 9
7 3
13 20
15 10
2 11
4 13
2 15
20 19
3 4
12 5...

output:

Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice

result:

wrong answer 1st lines differ - expected: 'Bob', found: 'Alice'

Test #5:

score: 0
Wrong Answer
time: 2ms
memory: 7388kb

input:

10
100 23
40 24
46 52
47 49
30 16
94 1
91 81
99 49
32 98
97 40
6 100
32 76
21 41
35 68
3 100
17 8
13 76
36 25
13 97
1 74
82 6
2 48
7 73
15 63
100 98
36 27
8 70
71 65
83 71
82 97
32 48
4 38
1 79
4 60
12 20
95 78
83 7
99 5
67 32
86 11
1 65
59 5
29 57
85 1
34 4
54 71
83 29
52 85
51 22
95 65
5 18
3 91
5...

output:

Bob
Alice
Alice
Alice
Bob
Bob
Bob
Bob
Bob
Bob

result:

wrong answer 2nd lines differ - expected: 'Bob', found: 'Alice'

Test #6:

score: 0
Wrong Answer
time: 2ms
memory: 7416kb

input:

10
100 41
86 2
69 67
60 51
75 97
87 95
82 81
86 14
52 65
51 42
40 10
55 11
51 85
14 61
23 90
44 53
78 40
76 96
12 31
49 80
53 41
72 88
97 30
15 32
47 20
41 79
29 72
59 100
22 95
65 30
3 21
43 88
75 57
69 37
38 64
80 5
42 53
58 46
73 24
34 68
88 48
81 33
100 78
22 4
15 4
78 100
58 24
81 9
7 43
22 61
...

output:

Alice
Alice
Alice
Alice
Alice
Alice
Bob
Bob
Bob
Bob

result:

wrong answer 2nd lines differ - expected: 'Bob', found: 'Alice'

Test #7:

score: 0
Wrong Answer
time: 2ms
memory: 6320kb

input:

10
100 31
17 7
24 21
43 21
34 20
100 59
83 47
3 76
3 39
9 29
81 3
49 80
46 34
74 100
8 46
8 70
69 7
45 1
79 31
60 46
26 72
33 30
97 65
100 52
4 27
57 64
45 8
66 51
29 51
1 48
11 21
4 35
100 67
96 16
78 11
74 57
81 70
90 32
87 5
73 75
13 100
88 84
49 62
85 9
61 7
73 7
92 37
59 88
28 26
4 7
10 84
33 6...

output:

Bob
Alice
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob

result:

wrong answer 1st lines differ - expected: 'Alice', found: 'Bob'

Test #8:

score: 0
Wrong Answer
time: 2ms
memory: 6128kb

input:

10
100 43
96 2
10 70
34 6
82 98
27 66
96 40
60 36
82 10
74 75
68 100
12 55
25 14
83 29
38 10
73 59
77 20
67 54
20 52
26 83
76 92
21 45
82 43
29 15
2 99
64 43
90 27
7 19
99 18
28 88
85 34
81 46
30 62
51 13
55 61
71 68
31 1
56 4
37 89
92 49
87 18
23 5
74 34
83 31
100 42
33 62
32 72
82 79
34 9
15 24
71...

output:

Bob
Alice
Alice
Bob
Alice
Alice
Bob
Alice
Alice
Alice

result:

wrong answer 6th lines differ - expected: 'Bob', found: 'Alice'

Test #9:

score: 0
Wrong Answer
time: 75ms
memory: 6180kb

input:

10
1000 43
772 422
642 2
299 28
330 35
12 520
59 471
298 696
526 289
692 263
518 5
786 236
261 324
676 859
644 140
891 162
903 718
870 597
47 695
135 212
438 567
972 408
238 405
62 913
939 696
717 602
612 991
642 99
878 347
755 679
281 216
506 180
633 712
455 621
878 791
354 515
196 712
449 48
76 10...

output:

Alice
Alice
Alice
Alice
Alice
Bob
Alice
Alice
Alice
Bob

result:

wrong answer 3rd lines differ - expected: 'Bob', found: 'Alice'

Test #10:

score: 0
Wrong Answer
time: 65ms
memory: 6120kb

input:

10
1000 553
733 308
955 950
122 694
335 139
579 404
360 386
761 48
713 69
885 900
572 425
407 375
660 441
712 175
581 570
552 42
30 550
905 619
406 361
641 83
372 903
116 126
622 940
633 378
171 954
672 571
985 991
426 818
512 276
801 969
604 567
51 104
239 826
603 404
84 401
152 219
790 216
773 457...

output:

Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob

result:

wrong answer 3rd lines differ - expected: 'Alice', found: 'Bob'

Test #11:

score: 0
Wrong Answer
time: 66ms
memory: 6124kb

input:

10
1000 123
514 970
370 473
77 91
436 836
896 508
624 417
472 282
332 981
478 210
261 983
111 853
977 115
604 43
315 322
459 748
34 696
156 976
458 677
444 481
185 717
478 284
411 104
452 780
551 298
610 543
184 700
652 111
390 537
836 377
418 218
69 353
509 371
154 733
561 307
592 734
566 784
183 7...

output:

Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Bob

result:

wrong answer 3rd lines differ - expected: 'Bob', found: 'Alice'

Test #12:

score: 0
Wrong Answer
time: 63ms
memory: 6260kb

input:

10
1000 754
37 554
412 364
267 659
867 456
45 647
232 357
238 962
481 983
282 762
899 857
959 444
767 165
510 37
311 407
638 201
670 539
338 911
509 906
390 10
455 106
989 874
806 355
262 169
635 666
2 727
522 9
696 951
35 637
650 887
651 79
629 572
721 60
221 307
337 485
174 617
644 696
252 133
854...

output:

Alice
Alice
Alice
Alice
Alice
Bob
Bob
Bob
Bob
Bob

result:

wrong answer 1st lines differ - expected: 'Bob', found: 'Alice'

Test #13:

score: 0
Time Limit Exceeded

input:

10
84430 84368
1 4154
4154 25649
3265 25649
3265 29300
29300 21812
3168 21812
19245 3168
19245 38447
8585 38447
8585 20837
24822 20837
11564 24822
11564 22829
31085 22829
16 31085
8178 16
8178 1261
1261 34782
34782 5026
31221 5026
17991 31221
17991 3048
34807 3048
34807 25533
25533 27170
27170 5175
...

output:


result:


Test #14:

score: 0
Time Limit Exceeded

input:

10
84806 84743
28461 1
28461 9961
9961 35696
35696 5273
5273 29126
29126 38289
38289 23507
23507 9
10 9
10 9186
9186 33743
5756 33743
5756 21120
15 21120
15 7483
7276 7483
7276 2978
2978 9436
9436 30448
30448 29729
29729 35238
35791 35238
19782 35791
25 19782
25 2780
15719 2780
397 15719
397 3758
37...

output:


result:


Test #15:

score: 0
Time Limit Exceeded

input:

10
82084 82065
37775 32530
40546 29469
23566 28044
35617 31751
31166 43373
28423 2499
11536 19058
23290 31161
26226 24568
18877 6176
9262 43955
18274 17232
32859 41405
20598 36180
21792 578
29778 31253
27189 4111
42776 34788
873 11571
15705 10303
8278 13795
5914 28364
32028 26693
36908 42138
11907 2...

output:


result:


Test #16:

score: 0
Time Limit Exceeded

input:

10
85000 84953
24621 1
24621 36903
36903 4
33359 4
33359 6
6 29846
29846 39656
39656 9
9 38842
10565 38842
10565 19413
19413 37160
37160 23025
23025 25488
25488 16
16 28458
28458 3388
22598 3388
20 22598
23875 20
37611 23875
16745 37611
16745 25981
16207 25981
16207 11402
18861 11402
18861 2058
2757...

output:


result:


Test #17:

score: 0
Time Limit Exceeded

input:

10
83316 83299
10033 32368
47502 24728
31682 30118
43973 15341
5822 34318
29780 19772
45970 34626
28002 797
9591 26973
35005 44537
33032 26612
30988 48652
33749 5045
5955 32860
44207 15678
28034 24354
29690 2207
17753 29140
9885 14486
28101 29900
20137 36123
13949 20079
21555 8761
16072 10804
42675 ...

output:


result:


Test #18:

score: 0
Time Limit Exceeded

input:

10
82231 82168
1 1849
30163 1849
30163 4532
4532 17392
11875 17392
11875 11168
11168 37043
37043 18205
18205 34868
34868 16425
11835 16425
21736 11835
21736 14
4486 14
2419 4486
2419 30930
501 30930
501 10928
10928 299
14095 299
4469 14095
3550 4469
3550 31592
11679 31592
11679 26
26 31897
31897 324...

output:


result:


Test #19:

score: 0
Time Limit Exceeded

input:

10
79873 79846
45043 31880
4441 30102
36418 17276
10371 28976
35848 28078
18719 6580
31379 47630
7873 25955
32444 31752
24751 26584
3314 3592
24794 29329
36094 45059
40891 8323
47741 45072
30083 33370
40224 35035
32323 38086
43309 12826
5965 47743
23015 25030
24013 37134
39574 22806
46940 40786
8273...

output:


result:


Test #20:

score: 0
Time Limit Exceeded

input:

10
85000 84974
35180 1
34572 35180
34572 5302
2266 5302
2266 6
12139 6
12139 8
8 20653
10 20653
8479 10
20975 8479
20975 2030
14373 2030
12416 14373
9969 12416
9969 34877
34877 15729
15729 36050
21424 36050
33717 21424
33717 27572
27572 20518
20518 3624
38796 3624
38796 8762
27 8762
27 34615
34615 3...

output:


result: