QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#478868 | #1000. 边三连通分量 | Williamxzh# | AC ✓ | 121ms | 49992kb | C++23 | 1.8kb | 2024-07-15 11:55:00 | 2024-07-15 11:55:00 |
Judging History
answer
#include <bits/stdc++.h>
#define il inline
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
typedef unsigned long long ll;
const int N=5e5+5,mod=48611;
int n,m,fa[N],ck[N],vis[N];ll a[N],b[N],w[N];
vector<pii> e[N];
il void adde(int x,int y,int z){e[x].push_back({y,z});}
mt19937_64 rnd(time(0));
struct MAP{
vector<pair<ll,int> > f[mod];
il void add(ll x,int y){int z=x%mod;f[z].push_back({x,y});}
il void change(ll x,int y){
int z=x%mod;
for(auto &it:f[z]) if(it.fi==x) {it.se=y;break;}
}
il int get(ll x){
int z=x%mod;
for(auto it:f[z]) if(it.fi==x) return it.se;
return 0;
}
}mp,to;
void dfs(int x,int pre){
ll u;vis[x]=1;
for(auto [y,z]:e[x]){
if(z==pre) continue;
if(!vis[y]) fa[z]=x,dfs(y,z),a[x]^=a[y];
else if(!w[z]) w[z]=rnd(),mp.add(w[z],1),a[x]^=w[z],a[y]^=w[z];
}
if(mp.get(a[x])) u=rnd(),b[x]^=u;
else{
int y=to.get(a[x]);
if(y) u=rnd(),b[x]^=u,b[y]^=u,to.change(a[x],x);
else to.add(a[x],x);
}
}
vector<int> f[N];int idx,id[N];
void dfs1(int x,int pre){
for(auto [y,z]:e[x]){
if(z==pre || fa[z]!=x) continue;
b[y]^=b[x],dfs1(y,z);
}
int u=mp.get(b[x]);
if(!u) mp.add(b[x],u=++idx);
f[u].push_back(x);
}
int x,y,z;
int main(){
//freopen("3edge.in","r",stdin);
scanf("%d%d",&n,&m);mp.add(0,1);
for(int i=1;i<=m;++i) scanf("%d%d",&x,&y),++x,++y,adde(x,y,i),adde(y,x,i);
for(int i=1;i<=n;++i) if(!vis[i]) ck[i]=1,dfs(i,0);
for(int i=0;i<mod;++i) mp.f[i].clear();
for(int i=1;i<=n;++i) if(ck[i]) dfs1(i,0);
printf("%d\n",idx);
for(int i=1;i<=idx;++i){printf("%d ",f[i].size());for(int x:f[i]) printf("%d ",x-1);puts("");}
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 14208kb
input:
4 5 0 2 0 1 3 0 2 1 2 3
output:
3 1 1 1 3 2 2 0
result:
ok OK
Test #2:
score: 0
Accepted
time: 2ms
memory: 14224kb
input:
13 21 4 5 8 7 12 3 3 10 1 5 10 2 0 0 11 4 2 12 9 1 9 0 7 8 7 6 9 1 8 2 12 10 11 0 8 6 3 2 5 9 4 11
output:
6 2 11 4 3 5 1 9 1 0 4 12 3 10 2 1 6 2 7 8
result:
ok OK
Test #3:
score: 0
Accepted
time: 110ms
memory: 48772kb
input:
200000 200000 127668 148778 77100 11865 85144 199231 39485 84917 102044 187263 130204 174776 26220 198288 162188 12078 92196 146334 120537 38083 150353 160479 18707 6545 101149 25450 62271 9177 38892 6454 11709 191939 89247 145109 140599 121858 197410 148980 55975 169098 128576 59852 68224 182347 89...
output:
156853 1 130053 1 109379 1 16951 1 96939 1 134977 1 83121 1 114344 1 49994 1 179006 1 197312 1 73479 1 106040 1 50807 1 165221 1 166649 1 68272 1 38289 1 142682 1 99836 1 12028 1 102803 1 27099 1 114474 1 82079 1 104348 1 189374 1 92254 1 150379 1 159181 1 179811 1 1402...
result:
ok OK
Test #4:
score: 0
Accepted
time: 104ms
memory: 49868kb
input:
200000 200000 150762 148756 172967 108322 69862 125085 84513 111056 141009 156725 36311 103205 31879 79919 62895 63377 21697 115522 161610 160423 113104 10277 106927 168428 136657 198931 52292 164110 149020 7038 115111 112823 35584 124385 45429 191603 96444 30523 195578 149089 160105 58103 139792 27...
output:
156961 1 125898 1 70394 1 53869 1 104669 1 129081 1 100681 1 41198 1 70879 1 112530 1 14934 1 108660 1 66365 1 24383 1 34481 1 138878 1 86552 1 89618 1 38043 1 54490 1 66419 1 120222 1 140638 1 17682 1 72554 1 89319 1 193209 1 93 1 171935 1 46988 1 199955 1 24166 1 954...
result:
ok OK
Test #5:
score: 0
Accepted
time: 121ms
memory: 49992kb
input:
200000 200000 53335 120202 193029 92221 8244 61648 50176 7825 97274 91479 85438 76999 26861 80116 162826 198446 160509 95916 143190 116619 121254 192931 121545 132273 149400 91882 97032 5048 179008 82221 187475 70697 159074 65868 158744 94466 120006 170635 36429 162768 61114 17876 131798 188508 1080...
output:
156803 1 29517 1 154139 1 130698 1 99640 1 140367 1 102247 1 198683 1 47273 1 187909 1 46326 1 22215 1 14473 1 189501 1 117986 1 18389 1 7084 1 132284 1 18675 1 32418 1 43432 1 156817 1 163858 1 151921 1 45282 1 153512 1 50415 1 7040 1 82344 1 100960 1 23893 1 81617 1 ...
result:
ok OK
Test #6:
score: 0
Accepted
time: 85ms
memory: 38552kb
input:
127669 148779 124640 77100 11865 117450 85144 68159 104241 39485 76372 84917 102044 56191 43704 26220 67216 31116 75749 123504 12078 92196 70006 15262 100591 74552 120537 38083 19281 29407 18707 6545 101149 25450 62271 9177 38892 6454 11709 119710 60867 89247 14037 9527 121858 66338 112298 81804 795...
output:
85614 1 94756 1 44517 1 47153 1 51915 1 12486 1 12214 1 98478 1 14748 1 53706 1 38686 1 22698 1 123435 1 15671 1 108457 1 98869 1 23082 1 76922 1 81699 1 29456 1 10660 1 83810 1 81407 1 30201 1 100714 1 103512 1 97281 1 24849 1 34179 1 80101 1 64953 1 113025 1 34833 1...
result:
ok OK
Test #7:
score: 0
Accepted
time: 76ms
memory: 41080kb
input:
150763 148757 108322 69862 125085 84513 111056 141009 36311 103205 31879 79919 62895 63377 21697 115522 113104 10277 106927 136657 52292 149020 7038 115111 112823 35584 124385 45429 96444 30523 149089 58103 139792 27250 15883 109949 69372 132387 141930 113408 65522 128254 138198 141969 42522 92075 1...
output:
119909 1 6807 1 71992 1 6544 1 19114 1 55003 1 109404 1 63787 1 123739 1 41567 1 123431 1 59083 1 114167 1 61359 1 29409 1 59280 1 14684 1 112390 1 145242 1 66891 1 137369 1 84292 1 90202 1 100462 1 3126 1 127606 1 29538 1 76163 1 18555 1 140975 1 41127 1 127342 1 2799...
result:
ok OK
Test #8:
score: 0
Accepted
time: 44ms
memory: 24596kb
input:
53336 120203 26685 8244 50176 7825 31738 24370 25943 19902 11463 26861 29977 26309 14580 31754 1838 29437 30380 12118 51083 31633 1201 18328 26346 5295 48935 19027 31496 19906 41783 5048 47936 16685 5161 34107 15907 28002 332 27672 28930 39563 36429 31696 17876 726 42526 21682 35319 8727 17974 25252...
output:
9550 1 14547 1 33221 1 25373 1 49362 1 14444 1 28138 1 46202 1 10768 1 17577 1 12568 1 28744 1 37853 1 593 1 10608 1 5154 1 40309 1 52185 1 33099 1 50252 1 8805 1 40238 1 20189 1 10803 1 26670 1 490 1 26482 1 1830 1 29947 1 28244 1 13456 1 19261 1 20287 1 407 1 31450...
result:
ok OK
Test #9:
score: 0
Accepted
time: 21ms
memory: 21420kb
input:
17707 71661 1354 3272 13699 17294 16733 9246 14993 5758 7252 2983 3813 6121 10450 14069 8088 11201 857 4420 12788 2032 11938 1465 10322 15171 14688 1857 2309 2742 2013 13200 14142 16319 10541 1922 10368 1516 7994 9092 3327 5166 13484 2876 15472 13522 15622 13479 3361 15314 15464 14974 17637 7535 435...
output:
354 402 17403 14234 2087 9434 4051 17358 13351 14409 4827 1994 10118 8936 945 2488 7003 645 10295 11605 7506 10078 4874 9463 2991 4591 16559 7865 2473 866 991 9349 11730 14033 3282 1223 17490 10866 13876 3557 7289 7665 8870 11661 9902 9854 4126 4448 9611 1187 17478 17170 16807 17446 17228 10838 1271...
result:
ok OK
Test #10:
score: 0
Accepted
time: 8ms
memory: 15856kb
input:
4294 17517 1175 3250 314 389 4272 3633 2938 1831 1307 2818 3321 347 1205 1428 2354 1478 1003 3898 1587 3443 1122 1512 2512 3995 348 3280 2064 1022 1834 2958 4281 1863 689 3613 2115 3708 1645 1488 1601 4181 916 4276 128 2626 4147 2868 87 1411 1802 1451 1254 2010 2936 3120 1065 277 1121 3284 3655 2849...
output:
99 213 2295 3190 3801 574 3030 2973 374 798 4239 1137 27 2802 845 3418 531 4257 3471 3107 4057 2404 2632 3922 638 536 824 3081 164 1643 2837 2369 2721 3689 3799 959 291 2396 2002 2863 4021 1030 2307 2738 1630 4028 10 2485 3118 4044 2003 3872 2145 2850 2208 594 2798 1622 3316 1144 286 3664 2569 4191 ...
result:
ok OK
Test #11:
score: 0
Accepted
time: 35ms
memory: 22140kb
input:
26686 105813 14774 5315 22701 21346 1398 13888 18566 18745 22298 6181 21347 10653 16500 23768 2329 5818 17512 16769 25519 338 12580 3064 19467 21665 3978 13202 23556 25178 195 9695 1472 13111 22925 24074 3026 13281 17666 14469 22007 18680 4159 13152 20431 23814 6671 10788 24433 13211 9794 12608 3264...
output:
553 486 4897 16625 21634 20916 10881 12499 1744 17493 25327 1161 9970 21588 11105 3367 25798 1842 5960 7314 2815 20024 9521 2705 2487 25557 25479 4110 7663 19941 8982 17547 1846 5846 24802 3363 9549 24592 20946 11684 15561 20722 24120 22466 25035 6037 20142 25741 16522 20140 8666 22219 1314 16809 81...
result:
ok OK
Test #12:
score: 0
Accepted
time: 52ms
memory: 24620kb
input:
36033 148595 33366 22486 14414 23855 2694 30361 16352 31902 27993 2048 4707 31743 30610 12884 23278 27069 10529 20914 2030 30015 24554 15673 10184 29423 17825 20383 34077 1181 25518 26129 6355 8810 2857 21736 25108 34280 14992 24299 32649 20227 34529 10407 23194 29913 10451 319 34666 8904 30811 3003...
output:
618 441 23917 18557 5405 14848 15322 4422 33260 16503 35379 16918 16504 30956 28508 515 6281 11617 17226 4653 5198 27377 25113 14728 1569 29959 8744 18782 29206 29486 15893 16676 4323 3752 12511 7014 35430 18574 10253 7067 8630 23276 4959 24774 502 16118 9887 5490 26187 9304 2285 21853 32262 6539 35...
result:
ok OK
Test #13:
score: 0
Accepted
time: 15ms
memory: 20372kb
input:
14868 57739 5724 2103 9214 3074 2269 531 3811 13162 5199 12632 6337 12078 12592 4977 3553 6975 5063 6622 1221 13056 4252 3705 7547 7879 1702 3685 4058 2503 7540 9423 4280 12228 574 6265 11876 2711 4805 7605 1468 4802 6921 1954 6350 2733 4429 5862 13549 14543 13809 5357 1509 11478 87 2676 6299 7060 1...
output:
387 329 13846 4262 2380 6357 4932 14082 8183 10659 5026 3570 7334 3916 13969 12856 4061 6355 5734 14065 8740 3341 13799 7333 2240 11247 8535 11327 612 11573 5979 8092 2974 11421 11589 8618 9885 13797 14440 11106 3513 3242 8486 13419 12879 7289 810 6646 10400 11801 95 4808 6183 1074 1005 13403 9097 2...
result:
ok OK
Test #14:
score: 0
Accepted
time: 2ms
memory: 12096kb
input:
53 43 32 44 25 10 24 49 20 28 28 44 16 12 37 48 46 36 30 47 25 3 17 31 19 17 29 42 25 44 30 3 31 21 2 34 42 12 22 50 12 52 39 10 0 46 29 1 12 21 3 0 11 31 42 25 4 51 26 36 19 48 39 26 5 21 7 41 29 34 38 47 29 8 26 17 42 46 36 20 39 30 13 27 28 31 27 24
output:
45 1 38 1 47 1 30 9 3 42 31 28 25 39 26 36 46 1 32 1 20 1 37 1 48 1 19 1 17 1 16 1 1 1 2 1 34 1 8 1 29 1 52 1 12 1 5 1 21 1 11 1 44 1 10 1 0 1 51 1 4 1 6 1 41 1 7 1 9 1 49 1 24 1 27 1 13 1 14 1 15 1 18 1 50 1 22 1 23 1 33 1 35 1 40 1 43 1 45
result:
ok OK
Test #15:
score: 0
Accepted
time: 2ms
memory: 12068kb
input:
70 21 39 34 29 33 38 53 37 7 47 64 47 17 65 66 60 39 37 47 19 68 14 28 39 41 52 55 0 60 59 16 11 40 11 33 35 26 0 11 24 17 26 43
output:
70 1 34 1 41 1 39 1 60 1 40 1 29 1 33 1 11 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 64 1 24 1 17 1 47 1 37 1 7 1 8 1 9 1 10 1 12 1 13 1 28 1 14 1 15 1 59 1 16 1 18 1 68 1 19 1 20 1 21 1 22 1 23 1 25 1 35 1 43 1 26 1 27 1 30 1 31 1 32 1 36 1 53 1 38 1 42 1 44 1...
result:
ok OK
Test #16:
score: 0
Accepted
time: 2ms
memory: 12644kb
input:
88 139 5 61 52 80 0 17 50 87 62 71 25 69 10 46 44 86 11 38 17 35 73 49 24 47 39 83 8 66 55 56 64 45 83 41 59 35 76 24 2 70 11 77 80 58 84 86 30 50 23 54 36 74 12 10 62 75 33 34 43 28 77 29 10 46 77 33 26 48 32 38 52 79 15 30 25 57 86 0 46 75 81 60 35 83 66 87 25 86 19 85 9 38 15 64 59 82 0 53 40 66 ...
output:
39 1 82 1 45 1 47 1 54 1 68 1 26 50 48 85 19 22 41 83 79 33 8 58 44 36 20 81 28 5 61 57 25 86 66 49 6 52 80 70 7 2 21 23 76 4 15 30 50 87 77 11 38 9 1 56 71 62 75 46 10 35 17 0 1 63 1 14 1 39 1 34 1 73 1 13 1 67 1 84 1 74 1 27 1 69 1 60 1 72 1 43 1 37 1 40 1 3 1 78 1 65 1 4...
result:
ok OK
Test #17:
score: 0
Accepted
time: 2ms
memory: 14236kb
input:
53 185 48 40 23 7 45 7 6 42 13 6 45 1 18 28 47 14 11 15 27 9 50 44 23 47 20 27 18 19 2 19 18 49 32 49 9 12 11 0 32 49 22 14 8 48 41 28 30 43 4 21 7 22 28 30 17 11 19 30 44 7 46 8 50 45 35 48 29 47 4 26 16 39 37 25 38 12 19 52 28 41 23 31 33 34 6 15 44 24 0 6 26 22 49 43 4 31 20 38 43 39 41 39 51 40 ...
output:
5 16 5 29 50 44 24 1 31 45 7 23 47 14 22 26 4 21 1 10 19 35 3 17 13 46 51 40 48 8 38 12 9 27 20 42 6 15 11 0 16 36 37 25 34 33 30 43 32 52 49 16 39 41 28 18 19 1 2
result:
ok OK
Test #18:
score: 0
Accepted
time: 2ms
memory: 14656kb
input:
70 252 63 36 64 48 26 34 43 37 30 53 67 64 26 19 25 54 28 44 52 60 4 22 43 48 14 48 12 50 37 23 28 40 48 54 60 23 43 46 7 5 29 39 5 13 57 60 1 23 33 8 59 39 3 29 5 8 34 11 44 40 39 19 40 17 42 48 39 19 49 46 0 48 46 45 57 67 43 60 56 59 32 42 6 54 56 69 23 43 38 65 66 24 0 64 16 10 23 1 4 16 37 49 5...
output:
6 28 19 2 50 12 53 30 41 35 33 8 61 69 56 11 55 9 21 13 68 26 34 3 29 39 59 62 7 5 1 63 1 20 17 58 27 31 38 65 4 22 36 10 16 47 24 66 44 28 40 17 1 18 22 45 14 1 23 37 43 46 49 6 54 25 15 51 42 32 52 60 57 67 64 48 0
result:
ok OK
Test #19:
score: 0
Accepted
time: 0ms
memory: 14956kb
input:
88 390 74 40 14 37 44 66 7 49 12 4 39 48 56 76 46 40 80 30 5 39 52 0 40 79 0 11 34 41 43 80 54 62 61 41 54 37 31 81 59 66 23 59 47 84 16 85 68 29 31 63 4 55 27 5 26 68 14 84 16 34 82 16 62 54 46 15 65 63 58 83 5 36 67 19 65 42 35 25 82 73 55 59 28 36 22 38 46 79 61 34 51 40 69 42 36 5 26 38 86 14 22...
output:
14 7 46 15 51 17 74 40 79 6 83 3 58 21 70 18 9 42 69 8 13 63 65 81 31 67 6 27 60 48 39 5 36 8 28 64 6 50 24 49 7 86 5 11 45 75 52 0 7 14 37 54 62 78 47 84 1 10 5 87 35 25 32 19 7 57 61 34 41 85 16 82 7 1 2 72 43 30 80 73 5 29 68 26 38 22 6 33 77 9 56 76 20 9 59 71 23 12 4 55 53 44 66
result:
ok OK