用户输出
No
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#69280 | #1262. 系统漏洞 | Accepted | 100 | 2297 ms | 10148 K | C++ 11 / 951 B | Shirost | 2022-05-13 14:23:30 |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;
int fastmod(int x, int p) {
int res = 1;
while (p) {
if (p & 1)
res = 1ll * res * x % mod;
x = 1ll * x * x % mod;
p >>= 1;
}
return res;
}
int T;
int n, m;
int head[N], to[N * 2], nxt[N * 2], val[N * 2], cnt;
void add(int x, int y, int z) {
to[++cnt] = y;
val[cnt] = z;
nxt[cnt] = head[x];
head[x] = cnt;
}
int vis[N], num[N];
int fl;
void dfs(int x) {
vis[x] = 1;
for (int i = head[x]; i; i = nxt[i]) {
int y = to[i], z = val[i];
if (vis[y]) {
if (1ll * num[x] * z % mod != num[y]) {
fl = 1;
return;
}
} else {
num[y] = 1ll * num[x] * z % mod;
dfs(y);
}
}
return;
}
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= m; ++i) {
int x, y, z;
scanf("%d%d%d", &x, &y, &z);
add(x, y, z);
add(y, x, fastmod(z, mod - 2));
}
for (int i = 1; i <= n; ++i)
if (!vis[i]) {
fl = 0;
num[i] = 1;
dfs(i);
if (fl) {
puts("No");
return 0;
}
}
puts("Yes");
return 0;
}
用户输出
No
系统信息
Exited with return code 0
用户输出
Yes
系统信息
Exited with return code 0
10 17
6 5 265734983
4 9 631933499
1 2 450290420
7 1 577953100
3 8 92694360
10 3 761646389
3 6 392253
<146 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
用户输出
Yes
系统信息
Exited with return code 0
用户输出
Yes
系统信息
Exited with return code 0
用户输出
Yes
系统信息
Exited with return code 0
7 21
2 6 663227492
7 4 461354276
3 4 28152109
6 4 358823726
5 2 619487277
3 7 260147635
3 1 87740519
<196 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
8 13
7 8 522627804
7 2 400792198
6 7 220572477
8 6 772420713
4 5 949106732
1 2 867088911
6 3 8508517
<87 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
7 17
5 6 278219751
1 2 888194392
7 5 422277480
4 1 438560464
4 6 86173934
6 7 738154829
2 5 14937829
<140 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
9 30
1 9 767960951
4 1 843961520
4 5 753611695
7 8 994435066
2 5 996986937
6 7 979505444
7 1 7978885
<323 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
69862 16243
61420 64532 280460887
32912 33645 212682531
22783 31406 94042606
47240 23816 532005326
5
<350456 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
827 21822
18 821 642462789
513 112 311836307
240 658 73121766
16 246 579367910
208 423 117505817
179
<384636 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
21170 14190
12190 1919 829256837
13172 14442 754634128
13158 17979 219895002
7962 3318 745811773
200
<295474 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
9663 84196
8297 1879 292786372
9215 397 652140130
7444 9475 230784857
3715 5438 451941544
940 2271 3
<1655101 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
24363 46728
11279 14632 838193751
22537 8614 985775026
2002 239 575454959
14348 19836 897828533
1626
<980005 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
75774 97925
27616 29383 814253970
46864 71571 495830926
6229 28188 834105682
53892 48713 492017500
6
<2114679 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
3257 54391
1478 1881 405181854
2268 2418 266963650
1942 3061 811310494
1309 2846 602605161
1285 1372
<1044778 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
93836 96085
26437 6661 172197286
72936 28639 8334549
67103 81135 845010863
46695 90447 845089693
155
<2080210 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
59423 8731
48994 48904 532953843
29413 16950 230007051
45437 49477 783665121
58732 15777 598315126
5
<187825 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
1669 44970
1289 881 580615741
199 305 544628212
124 987 889744111
651 5 650335708
1016 723 372958146
<834718 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
用户输出
No
系统信息
Exited with return code 0
用户输出
No
系统信息
Exited with return code 0
用户输出
No
系统信息
Exited with return code 0
58 58
57 3 722760617
32 36 171264773
13 31 44730833
1 40 87130412
42 58 3417203
55 5 901886978
8 57
<806 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
90 90
57 58 941826818
72 40 195753399
22 35 806912742
66 36 139491775
12 65 387857396
67 1 534587223
<1316 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
76 76
13 67 966109622
38 57 511467548
60 43 576483950
74 51 232074202
30 21 520711281
40 56 70237577
<1098 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
87 87
79 59 492248736
29 77 268859576
57 75 1746299
48 38 538290887
16 53 32693878
73 47 715536633
2
<1262 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
90 90
42 1 168840500
20 72 98256048
72 71 826924202
23 32 388345772
82 63 916254148
58 27 960737025
<1320 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
50 50
27 26 194828123
14 25 104316105
3 18 519246857
1 8 261364210
23 39 176385936
24 21 349844488
4
<681 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
95 95
49 75 456417824
27 49 611789516
29 91 731424411
68 43 626494606
75 8 162416612
9 58 574453
32
<1395 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
70 70
58 52 893000376
15 47 371864567
38 64 231332246
28 22 334361720
33 28 420856432
44 34 69656399
<1002 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
85 85
76 55 626156396
49 68 31227489
18 13 662783538
45 40 404470486
39 54 888049015
27 23 885800414
<1236 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
65 65
40 42 134507315
56 17 494985473
21 29 289192069
60 36 438451192
54 24 163939579
52 64 26294135
<923 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
76 76
57 18 353998981
18 9 658683093
45 28 65402770
12 76 693651599
10 65 373843948
3 15 320571241
1
<1093 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
62 62
60 5 938153507
48 60 284222348
8 33 760354302
9 7 61920112
5 22 144697494
15 13 140869729
35 4
<874 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
62 62
53 2 46115500
13 44 605918890
60 23 506746254
19 33 944164035
47 16 655723636
49 21 661550730
<871 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
80437 3978
35675 38813 4
24183 39469 256
19168 31068 4
44593 41996 2
50466 51083 2
7111 49257 128
42
<58437 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
57998 12749
40593 53567 1296
39158 13652 36
16731 20569 6
50986 26053 36
35508 43413 10077696
42480
<217328 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
73634 44192
36369 66120 262144
24363 13106 512
50687 48522 64
57886 61765 2097152
51379 6684 4096
26
<782570 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
83681 6014
34011 76484 100000000
83194 32199 100000
158 48676 100000
59510 36140 10
47489 21626 10
6
<112834 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
99841 69443
10536 66148 3125
5881 68378 625
3243 34972 78125
6730 53230 390625
51505 23789 3125
6143
<1165227 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
52032 81906
34361 29797 4
51771 11046 1024
43489 35063 4
20777 50052 16384
1105 36707 64
47402 33300
<1320571 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
84545 66452
64482 22473 256
45422 78047 2
65038 7726 512
25645 14038 128
3320 51532 512
24745 60760
<978910 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
95284 12151
19538 42416 2187
50499 58575 81
65938 54961 27
7508 85288 19683
83231 82309 19683
51477
<188631 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
87882 58606
43955 20541 134217728
33499 75042 134217728
80147 64426 2097152
35188 29060 64
60135 359
<1039495 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
55968 29261
48535 37181 10000
23691 5745 10000
6159 9 1000
22430 22323 10000
32676 33330 100
43328 7
<544389 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
99921 82960
56086 35222 1088
51673 7949 320
10248 34571 543340224
68425 51548 852418080
56104 18597
<1586681 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
99955 35896
86228 95544 1962
81241 58831 722710800
56643 18823 590768640
24775 50348 69200
55746 786
<749927 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
99931 6476
62307 83325 753602400
78808 98377 922143600
98031 19792 225907200
42614 42933 886540864
7
<140564 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
99950 7006
16229 48247 609640668
2356 57017 774385650
28294 63873 504221088
16847 69959 729906800
19
<151903 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
99987 67138
27484 32631 336139804
96936 59194 333596340
6564 32733 17681490
26379 8320 375070150
171
<1323570 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
99977 49316
56559 75600 157842
63054 97932 2222850
39756 29557 710397165
54484 24245 868791264
12952
<1005834 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
99929 71256
42110 3455 194745600
14589 39023 759758400
53116 22364 124416
2708 44115 17217720
47012
<1394554 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
99991 79018
49566 88155 391872000
82125 43840 829848
19372 93218 71082144
94597 42710 159144
80026 7
<1523288 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
99904 25294
72726 39623 641771676
49896 42523 662835780
40025 15649 534851352
93960 5954 535550400
6
<537344 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
99998 55226
4797 5465 1
43626 13860 116984175
70119 45659 983549952
79837 5538 990451000
90965 58135
<1114039 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
99993 33916
99321 5059 999953058
19089 73128 999953058
62151 39780 999953058
26669 43948 999953058
4
<738388 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
99997 36294
38402 43620 999927695
38295 94944 999927695
15090 16467 999927695
6017 47864 999927695
4
<790394 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
99988 31784
98789 34461 999954292
55376 19998 999954292
79576 53284 999954292
5363 28339 999954292
2
<692218 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
99941 99980
36255 5892 1
74172 50150 1
51940 5931 1
89395 21719 1
51848 75473 1
51006 18172 1
21795
<1377474 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
99959 99925
26588 66147 1
94494 28780 1
64625 62391 1
38447 39673 1
25006 44614 1
80452 4618 1
2541
<1376410 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
99999 99933
96608 85505 1
43823 23293 1
20447 18961 1
91758 14028 1
51701 14399 1
6983 74815 1
59578
<1376663 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
99244 99985
6928 4755 4
45742 12698 512
94686 4755 512
85881 4755 8192
83891 80240 4
13891 59134 2
5
<1647809 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
99296 99963
70831 15689 1
14441 39014 1
70831 87349 1
50761 65854 1
46024 87349 1
38900 46024 1
1444
<1388276 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
99219 99919
39483 5673 353
39483 5673 353
39483 5673 353
39483 5673 353
39483 5673 353
39483 5673 35
<1498697 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
431 92665
108 35 625
395 127 5
158 116 1
216 263 125
153 3 3125
255 83 125
192 135 125
426 109 125
3
<1010476 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
417 86736
187 158 343
326 27 49
342 270 1
10 138 7
312 234 49
245 313 7
346 216 7
400 10 2401
42 99
<918529 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
421 88410
168 173 128
306 189 1
142 301 2
291 399 2
289 215 2
95 21 16
39 239 4
416 203 2
62 280 16
<877756 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
99935 99935
97607 93154 332918785
89358 62130 78650600
80034 75186 131967121
82362 46759 306527835
7
<2165250 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
99981 99981
25482 51509 261536997
4678 3245 253622279
645 88468 457364243
35863 85669 667939
97810 8
<2166088 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
99917 99917
24388 41222 479671040
83177 55832 774731421
23298 79287 990929123
4660 19428 482261415
6
<2164709 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
99914 99914
80312 9196 833370116
84185 39108 241697944
58172 68694 569966274
54138 8968 442953526
45
<2164690 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
99981 99981
3103 88052 321934787
72207 70020 907899927
62415 57915 599954962
33778 76486 669058268
3
<2166077 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
99980 99980
32782 76976 750882719
64245 34464 432954865
10509 24663 537085432
10399 76875 179140035
<2166223 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
99977 99977
46775 27490 170815140
57325 42365 502462772
36797 31693 645122569
88113 35471 213376071
<2166202 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
99931 99931
45096 34610 894462728
62187 7626 556602678
76484 67523 988058584
62856 6688 305126833
92
<2165226 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
99972 99972
74619 47872 474607996
11549 97920 669654757
95852 86900 725721522
96461 24841 292139172
<2166158 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
99962 99962
94210 95045 545266489
53558 49182 128235934
6058 3590 193520377
74687 61257 876234476
24
<2165800 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
100000 100000
31453 9141 335579
29845 46034 126733
39896 57848 293149
81017 34154 19333
91468 73465
<1855668 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
100000 100000
50797 64035 1152841
84441 85316 1089497
3370 19593 826201
46010 40232 1058767
75494 44
<1920708 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
100000 100000
30595 16841 380200393
14236 7323 564707551
28386 7358 125619293
47525 21667 450873389
<2167254 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
100000 100000
76496 5372 851734087
97369 88063 984924503
61738 85381 343111187
35315 3377 402433643
<2167254 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
100000 100000
91967 14292 847088773
59320 6024 488917391
5418 82050 862457879
14043 88816 230570621
<2167308 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
100000 100000
10148 7953 772545751
27687 74445 318803179
47219 3943 206754161
92992 85390 717821437
<2167192 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
100000 100000
2695 87555 864497303
96654 63004 763154321
28289 26796 762890581
76976 41767 394804811
<2167024 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
100000 100000
13046 32515 228012643
20958 6508 106160177
93488 45615 535570153
34796 71416 91316179
<2166944 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
100000 100000
69360 15311 863990557
40286 42825 881179661
84451 9317 702772193
20102 33218 275223833
<2166902 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
100000 100000
5045 56518 821545817
73287 95921 352980233
48100 66213 132478901
32840 29264 626310143
<2167372 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0