QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#365274#6666. Graflukap_0 104ms27532kbC++143.1kb2024-03-24 23:25:212024-03-24 23:25:21

Judging History

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

  • [2024-03-24 23:25:21]
  • 评测
  • 测评结果:0
  • 用时:104ms
  • 内存:27532kb
  • [2024-03-24 23:25:21]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int MAXN = 2e5 + 500;
const int MAXM = 3e5 + 500;

int n, m;
vector<pair<int, int> > susjedi[MAXN], bridovi;
int maknut[MAXM];
int provc[20], provv[20], kolko, bio[MAXN], d[MAXN], w[MAXN];
vector<int> v;
int cnt;

void dfs (int x) {
    v.push_back (x);
    bio[x] = cnt;
    w[x] = 1;
    for (auto it: susjedi[x]) {
        if (maknut[it.second]) continue;
        int nx = it.first;
        if (bio[nx] != cnt) {
            d[nx] = d[x] + 1;
            dfs (nx);
            w[x] += w[nx];
        }
        bridovi.push_back ({x, nx});
    }
}

int pogle (int x, int y) {
    for (auto it: susjedi[x]) bio[it.first] = 0;
    for (auto it: susjedi[y]) bio[it.first] = 0;

    for (auto it: susjedi[x]) {
        if (maknut[it.second]) continue;
        bio[it.first]++;
    }
    for (auto it: susjedi[y]) {
        if (maknut[it.second]) continue;
        bio[it.first]++;
    }

    int vrati = -1;
    for (auto it: susjedi[x]) {
        if (!maknut[it.second] && bio[it.first] == 2) {
            if (vrati == -1) vrati = it.first;
            else return -1;
        }
    }
    return vrati;
}

bool solve (int x, int k) {
    v.clear ();
    bridovi.clear ();
    cnt++;
    d[x] = 0;
    dfs (x);
    if (v.size () != provc[k]) return false;
    if ((bridovi.size () / 2) != provv[k]) return false;
    if (k == 0) return true;

    int a = -1, b = -1, c = -1;
    for (auto it: bridovi) {
        int x = it.first, y = it.second;
        int z = pogle (x, y);
        if (z == -1) continue;

        if (d[x] > d[y]) swap (x, y);
        if (d[y] > d[z]) swap (y, z);
        if (d[x] > d[y]) swap (x, y);

        if (w[z] == provc[k] / 3 && v.size () - w[y] == provc[k] / 3) {
            if (a != -1 && ((a != x || b != y || c != z))) return false;
            a = x;
            b = y;
            c = z;
        }
    }
    if (a == -1) return false;

    for (auto it: susjedi[a]) {
        if (it.first == b) maknut[it.second] = 1;
        if (it.first == c) maknut[it.second] = 1;
    }
    for (auto it: susjedi[b]) {
        if (it.first == c) maknut[it.second] = 1;
    }

    if (solve (a, k - 1) && solve (b, k - 1) && solve (c, k - 1)) return true;
    return false;
}

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

    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;b--;
        susjedi[a].push_back ({b, i});
        susjedi[b].push_back ({a, i});
    }
    provc[0] = 1;
    provv[0] = 0;

    for (int i = 0; i < 12; i++) {
        if (provc[i] == n && provv[i] == m) {
            kolko = i;
            break;
        }
        if (i == 11) {
            cout << "ne";
            return 0;
        }
        provc[i + 1] = provc[i] * 3;
        provv[i + 1] = provv[i] * 3 + 3;
    }


    for (int i = 0; i < n; i++) {
        if (susjedi[i].size () % 2 == 1) {
            cout << "ne";
            return 0;
        }
    }

    if (solve (0, kolko)) cout << "da";
    else cout << "ne";

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 15
Accepted
time: 2ms
memory: 8328kb

input:

9 12
7 9
1 5
8 5
4 6
3 4
1 8
6 3
7 5
2 9
4 5
7 4
2 7

output:

da

result:

ok single line: 'da'

Test #2:

score: 0
Accepted
time: 0ms
memory: 8328kb

input:

9 12
8 5
3 9
1 7
7 2
3 6
3 7
4 7
1 4
5 2
8 2
6 9
3 2

output:

da

result:

ok single line: 'da'

Test #3:

score: 0
Accepted
time: 2ms
memory: 8364kb

input:

9 13
3 1
9 7
2 4
7 8
8 7
5 6
9 8
3 4
8 2
4 8
2 5
2 6
4 1

output:

ne

result:

ok single line: 'ne'

Test #4:

score: 0
Accepted
time: 0ms
memory: 8340kb

input:

9 13
5 4
1 5
8 7
8 5
3 2
5 2
2 6
6 3
7 9
1 4
2 8
9 8
8 9

output:

ne

result:

ok single line: 'ne'

Test #5:

score: 0
Accepted
time: 0ms
memory: 8276kb

input:

9 12
4 2
3 5
3 7
2 7
2 1
2 8
1 4
5 4
7 5
8 4
7 1
3 2

output:

ne

result:

ok single line: 'ne'

Test #6:

score: 0
Accepted
time: 0ms
memory: 8384kb

input:

9 13
7 5
6 5
4 9
3 2
6 1
5 2
7 9
1 8
7 4
6 7
5 3
8 6
1 8

output:

ne

result:

ok single line: 'ne'

Test #7:

score: 0
Accepted
time: 2ms
memory: 8332kb

input:

9 12
2 6
5 1
8 4
6 3
7 2
9 5
9 1
3 4
6 9
3 8
6 7
6 1

output:

ne

result:

ok single line: 'ne'

Test #8:

score: -15
Wrong Answer
time: 0ms
memory: 8336kb

input:

9 12
2 6
1 2
2 5
3 8
1 6
2 9
5 9
7 1
3 6
6 8
4 1
7 4

output:

ne

result:

wrong answer 1st lines differ - expected: 'da', found: 'ne'

Subtask #2:

score: 0
Wrong Answer

Test #35:

score: 20
Accepted
time: 3ms
memory: 8368kb

input:

729 1093
340 310
430 713
576 240
138 297
618 162
328 418
143 713
568 220
252 387
219 400
593 491
330 472
722 643
679 598
356 112
701 213
344 408
500 190
225 72
351 688
283 542
215 449
135 194
306 382
266 83
576 289
563 721
345 656
567 694
580 355
127 487
352 310
687 322
620 520
583 466
678 308
19 10...

output:

ne

result:

ok single line: 'ne'

Test #36:

score: 0
Accepted
time: 3ms
memory: 8320kb

input:

729 1092
638 250
254 320
297 589
143 720
686 343
468 25
722 60
190 624
421 63
612 42
270 146
577 541
70 707
363 484
286 178
643 210
112 70
7 455
211 431
209 484
386 45
585 402
184 326
557 382
180 406
30 686
299 634
268 97
342 687
172 377
233 505
86 174
105 372
333 466
491 579
390 465
477 176
348 427...

output:

ne

result:

ok single line: 'ne'

Test #37:

score: 0
Accepted
time: 3ms
memory: 8300kb

input:

729 1092
301 205
596 371
190 64
77 258
283 304
306 454
210 177
327 251
20 388
185 482
339 284
313 586
368 338
612 47
613 323
559 114
233 296
271 397
705 714
125 159
49 496
286 174
278 521
456 134
422 123
201 283
314 599
354 328
492 339
49 153
628 334
275 190
505 275
326 15
241 348
42 102
65 717
224 ...

output:

ne

result:

ok single line: 'ne'

Test #38:

score: 0
Accepted
time: 0ms
memory: 8376kb

input:

243 363
31 225
187 117
147 160
229 44
168 179
164 107
173 146
78 102
47 50
38 13
222 83
115 24
14 240
185 61
199 111
119 225
98 80
126 102
42 235
43 216
59 129
109 193
179 27
218 142
114 50
46 174
47 99
120 6
103 221
136 187
19 191
65 180
57 160
166 83
185 229
48 139
114 143
150 101
208 80
24 74
7 6...

output:

ne

result:

ok single line: 'ne'

Test #39:

score: 0
Accepted
time: 3ms
memory: 8292kb

input:

729 1093
73 12
701 403
473 596
214 290
248 310
317 639
507 457
298 227
185 326
430 27
61 34
547 636
99 685
607 45
6 101
283 377
310 33
42 132
573 647
483 658
112 113
647 324
518 616
302 247
71 465
586 187
81 396
621 606
435 498
667 677
24 333
414 497
111 164
510 628
665 82
325 719
536 556
719 704
24...

output:

ne

result:

ok single line: 'ne'

Test #40:

score: 0
Accepted
time: 3ms
memory: 8364kb

input:

729 1092
663 607
327 712
424 22
507 89
138 363
465 228
129 291
389 682
73 477
581 622
582 543
78 487
55 479
186 50
619 167
490 615
677 191
42 574
323 136
283 120
433 325
531 530
144 24
620 239
368 225
12 166
452 686
361 526
248 709
586 606
39 110
229 696
686 647
260 333
403 150
88 462
529 449
513 35...

output:

ne

result:

ok single line: 'ne'

Test #41:

score: -20
Wrong Answer
time: 0ms
memory: 8388kb

input:

729 1092
659 490
150 263
166 478
382 659
135 290
603 656
601 301
64 689
81 160
197 133
438 593
379 482
522 493
238 72
362 664
648 240
471 168
32 153
282 407
648 492
276 218
593 106
193 537
613 369
632 167
235 236
663 319
37 416
577 659
111 601
578 483
645 529
100 636
457 312
200 161
515 344
591 706
...

output:

ne

result:

wrong answer 1st lines differ - expected: 'da', found: 'ne'

Subtask #3:

score: 0
Wrong Answer

Test #69:

score: 15
Accepted
time: 74ms
memory: 17008kb

input:

177147 265719
79646 110581
42107 166686
174516 92541
11418 84874
89568 79680
101533 167489
143016 26545
83401 102450
122789 91031
140172 64836
143906 82843
45757 98991
164963 130550
33432 152305
80043 16055
49162 39443
59476 89357
146429 111186
99327 115855
166381 89990
91164 139281
121510 124610
16...

output:

ne

result:

ok single line: 'ne'

Test #70:

score: 0
Accepted
time: 64ms
memory: 17016kb

input:

177147 265719
38681 77992
106972 53905
88649 110477
113934 98724
78662 109263
134699 83502
31991 92472
126170 144
119650 132169
84458 92531
24682 66176
131541 177081
97342 131339
103685 102763
130223 36375
142925 66285
105340 117815
111137 162166
43022 15242
120307 54486
78258 164394
52991 104308
65...

output:

ne

result:

ok single line: 'ne'

Test #71:

score: 0
Accepted
time: 104ms
memory: 27484kb

input:

177147 265719
80151 35717
121902 3023
160759 169382
24887 142159
40782 159514
23600 98839
121180 62418
122763 152478
148678 114794
11943 72581
173127 2884
97280 4969
155030 45742
120300 148466
134742 140635
79483 24583
71636 91841
140421 126108
44434 53426
133218 79051
161302 161964
59589 111719
961...

output:

ne

result:

ok single line: 'ne'

Test #72:

score: 0
Accepted
time: 64ms
memory: 15944kb

input:

177147 265719
23535 148931
151961 42693
126734 69633
41675 97286
148290 110970
18165 83792
5192 133074
101128 76523
76671 146056
37165 145496
108304 76746
47477 140906
73419 48220
39470 54859
81251 91381
88943 87801
102113 126514
153800 35348
116125 49494
114248 11690
150336 26095
40669 90388
3210 9...

output:

ne

result:

ok single line: 'ne'

Test #73:

score: 0
Accepted
time: 68ms
memory: 15988kb

input:

177147 265720
170712 62225
99915 128584
115624 72186
110450 90393
65021 158547
110390 161798
28967 132365
78897 47218
68752 69351
40606 17503
79654 32708
98155 146206
156781 52063
126696 159590
11625 167534
29472 10242
143508 43084
154423 175381
150212 141153
5882 3903
142063 39110
158366 31577
2263...

output:

ne

result:

ok single line: 'ne'

Test #74:

score: -15
Wrong Answer
time: 104ms
memory: 27108kb

input:

177147 265719
67351 167238
129901 55608
68480 135374
104799 141169
109735 94431
87690 136110
134896 150128
94005 84319
29006 124099
31988 157247
99008 24808
30090 15310
10480 16443
98191 89543
98109 139907
59896 166679
121226 129438
83139 84515
163834 143237
162513 60464
6858 120706
23808 13193
8871...

output:

ne

result:

wrong answer 1st lines differ - expected: 'da', found: 'ne'

Subtask #4:

score: 0
Wrong Answer

Test #103:

score: 50
Accepted
time: 61ms
memory: 17080kb

input:

177147 265719
132920 57252
64370 50983
162323 103641
126430 64347
64421 107962
35533 30427
171597 160614
120187 121996
103235 117200
122594 156637
121481 108177
115386 6337
28269 153079
43775 171594
164425 165290
59340 170257
20858 74213
162837 103195
171976 121082
68853 33317
152714 8959
47095 9036...

output:

ne

result:

ok single line: 'ne'

Test #104:

score: 0
Accepted
time: 58ms
memory: 15984kb

input:

177147 265720
98251 19107
36929 5082
59297 17482
166275 130189
125119 161493
151977 35937
4540 92380
52037 36475
105282 76892
8397 7997
162679 100647
12685 34568
53625 30405
136245 147693
95596 151955
66119 156086
92822 98840
66600 97472
42324 130091
34459 150929
81661 38148
1174 30859
113776 90353
...

output:

ne

result:

ok single line: 'ne'

Test #105:

score: 0
Accepted
time: 16ms
memory: 11292kb

input:

59049 88572
14041 31673
1168 11350
38714 28802
37877 22048
49987 22707
26786 49980
2818 13974
10003 17358
51907 30794
16816 20935
8685 53622
49148 54509
3371 26238
50806 4657
57731 38759
38131 9810
28974 19191
5485 27763
9140 36793
45914 17712
23433 31979
29334 8721
7313 42734
12130 24011
36906 5164...

output:

ne

result:

ok single line: 'ne'

Test #106:

score: 0
Accepted
time: 55ms
memory: 17052kb

input:

177147 265719
119867 167070
130132 12752
120764 56321
15572 66501
139543 82691
70068 42197
61383 135281
122332 161897
68678 68884
51691 172281
33415 150511
101102 101300
108117 151586
39194 21123
173495 82522
134499 170131
15461 53912
114257 106087
137475 32697
31578 172314
139488 145536
118015 1288...

output:

ne

result:

ok single line: 'ne'

Test #107:

score: 0
Accepted
time: 59ms
memory: 17028kb

input:

177147 265719
32229 30186
75313 76163
111944 168135
43914 37095
22266 44860
166052 93754
169557 55704
108797 163872
45432 112994
80343 100383
110188 66178
135008 105902
155873 72661
44225 151314
2720 88316
66950 133820
20039 85930
91897 17236
40370 91049
112750 27809
48067 13266
126431 53691
127666 ...

output:

ne

result:

ok single line: 'ne'

Test #108:

score: 0
Accepted
time: 16ms
memory: 10864kb

input:

59049 88572
26511 33490
28852 45905
27461 12238
3574 21240
10401 47111
25108 30094
41731 23065
34029 50912
24637 3051
39816 52369
17677 44545
29603 11717
24661 41876
6322 19702
11178 38322
12480 26080
47105 3194
12178 36578
32634 16221
25540 24583
42234 24601
15926 7470
5428 20505
18895 24343
6641 2...

output:

ne

result:

ok single line: 'ne'

Test #109:

score: 0
Accepted
time: 65ms
memory: 15988kb

input:

177147 265719
109974 161035
10257 149062
121470 37587
101821 92037
121099 27132
31616 170660
46299 85346
105465 61610
133310 53913
20419 23471
11021 49161
161237 108062
27418 106411
42549 75808
90998 78111
32550 19003
10562 170797
77403 67800
34756 24189
88268 56154
14749 154026
5889 159314
104655 1...

output:

ne

result:

ok single line: 'ne'

Test #110:

score: 0
Accepted
time: 59ms
memory: 16016kb

input:

177147 265719
108664 58201
64269 6343
120585 157969
151929 136534
168726 15269
25610 60139
11181 158806
139226 97957
107369 141067
135947 160932
162045 50711
105512 5940
172321 5888
7221 99888
120318 20857
24810 151590
135587 8881
143228 24034
6096 39018
73071 58377
173193 124153
97410 69946
74197 7...

output:

ne

result:

ok single line: 'ne'

Test #111:

score: 0
Accepted
time: 62ms
memory: 17012kb

input:

177147 265719
32981 44699
147062 61378
88263 172913
58385 30028
98963 22183
21517 65343
40334 104039
63687 1318
136538 117786
2824 90817
170979 107527
93628 112008
35891 28456
164720 154877
2494 115639
119501 113995
31926 105269
92857 99010
174834 17842
11538 142621
125432 105466
135353 157000
68024...

output:

ne

result:

ok single line: 'ne'

Test #112:

score: 0
Accepted
time: 55ms
memory: 17032kb

input:

177147 265719
167966 17672
92091 174891
69156 176406
144245 124379
124290 42270
59738 92303
86870 83034
79441 52547
15702 45945
164475 43564
132133 61402
27448 122029
45378 131195
35639 152970
550 29347
134069 145338
111946 144913
58629 120345
90261 66787
8482 156139
106048 76828
151397 165340
22520...

output:

ne

result:

ok single line: 'ne'

Test #113:

score: 0
Accepted
time: 65ms
memory: 15896kb

input:

177147 265720
84549 59066
8533 97512
95654 45173
28525 150968
86580 149227
57726 67651
52781 160528
97950 141266
100850 14838
166553 138190
61634 14254
57547 24000
168524 11255
116362 130964
170815 172567
120074 7542
128396 3289
29898 125597
163966 69876
50139 142020
84785 71240
22378 26807
135344 1...

output:

ne

result:

ok single line: 'ne'

Test #114:

score: 0
Accepted
time: 47ms
memory: 15996kb

input:

177147 265719
68898 132920
29665 73506
20531 169214
103475 58989
61733 32239
151574 63398
119411 169525
24793 25207
41292 44383
133706 111802
174419 1600
74876 147063
161499 174674
10278 7799
123599 8481
146302 166032
1313 90856
60646 95512
106779 134984
41603 43637
15001 37449
153582 123699
108004 ...

output:

ne

result:

ok single line: 'ne'

Test #115:

score: 0
Accepted
time: 16ms
memory: 10828kb

input:

59049 88573
48002 20129
7630 33065
13470 58907
56979 49428
24783 51171
35198 55138
26000 13842
56782 34295
54165 5732
52635 46706
40182 1575
48144 56529
25104 1814
30791 45557
24736 48013
51257 51882
26582 54128
26950 47776
18073 51674
24939 54097
24871 44506
23664 28536
3218 34786
44770 14839
46589...

output:

ne

result:

ok single line: 'ne'

Test #116:

score: -50
Wrong Answer
time: 101ms
memory: 27532kb

input:

177147 265719
134788 176770
110415 30012
70814 170685
31716 97968
166427 107186
55319 99947
990 168895
127047 57299
122397 109455
67762 167879
120077 134331
18803 64603
48445 33935
104943 45500
128895 87604
148759 151945
94766 103320
129651 15389
26640 140574
173781 39496
132805 125367
168455 59830
...

output:

ne

result:

wrong answer 1st lines differ - expected: 'da', found: 'ne'