QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#787784#7324. Eulerian OrientationTx_LcyAC ✓29ms16340kbC++141.8kb2024-11-27 14:37:032024-11-27 14:37:06

Judging History

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

  • [2024-11-27 14:37:06]
  • 评测
  • 测评结果:AC
  • 用时:29ms
  • 内存:16340kb
  • [2024-11-27 14:37:03]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline int read(){
	int s = 0;char ch = getchar();
	while(ch<'0'||ch>'9')ch = getchar();
	while(ch>='0'&&ch<='9'){s = (s<<1)+(s<<3)+ch-'0';ch = getchar();}
	return s;
}
mt19937_64 rd(time(0));
const int N = 200005,md = 1e9+7;
int hd[N],ect = 2,n,m,dfn[N],ct,kct;
ll sum[N],hsum[N],esum;
struct E{
	int v,nt;
	bool ite;
}e[2*N];
void add(int u,int v){
	e[ect].ite = 0;
	e[ect].v = v;
	e[ect].nt = hd[u];
	hd[u] = ect++;
}
map<ll,int> hc;
int hct;
void tarjan(int p,int lt){
	dfn[p] = ++ct;
	int v;
	for(int i = hd[p];i;i = e[i].nt){
		if(i==(lt^1))continue;
		v = e[i].v;
		if(!dfn[v]){
			e[i].ite = 1;
			tarjan(v,i);
		}else if(i&1){
			ll nrd = rd();
			sum[v]^=nrd;sum[p]^=nrd;
			if(!hc[nrd])hc[nrd] = ++hct,hsum[hct] = 0;
			hsum[hc[nrd]]++;
			esum++;
		}
	}
}
void dfs(int p){
	for(int i = hd[p];i;i = e[i].nt){
		if(!e[i].ite)continue;
		dfs(e[i].v);
		sum[p]^=sum[e[i].v];
		if(!sum[e[i].v])continue;
		esum++;
		if(!hc[sum[e[i].v]]){
			hc[sum[e[i].v]] = ++hct;
			hsum[hct] = 0;
		}
		hsum[hc[sum[e[i].v]]]++;
	}
}
ll fp(int p){
	ll x = 2,ans = 1;
	while(p){
		if(p&1)ans = ans*x%md;
		x = x*x%md;
		p>>=1;
	}
	return ans;
}
int main(){
	ll iv = fp(md-2);ll iiv = iv*iv%md;
	while(scanf("%d%d",&n,&m)>0){
		int u,v;
		hc.clear();
		ect = 2;kct = 0;hct = 0;esum = 0;ct = 0;
		for(int i = 1;i<=n;i++)dfn[i] = sum[i] = hd[i] = 0;
		for(int i = 1;i<=m;i++){
			u = read();v = read();
			add(u,v);add(v,u);
		}
		for(int i = 1;i<=n;i++){
			if(!dfn[i]){
				tarjan(i,0);
				kct++;
				dfs(i);
			}
		}
		ll ans = 0;
		for(int i = 1;i<=hct;i++){
			ans+=hsum[i]*hsum[i]%md*iv%md+(esum-hsum[i])*hsum[i]%md*iiv%md;
			ans%=md;
		}
		printf("%lld\n",ans*fp(m-n+kct)%md);
	}
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 9972kb

input:

4 4
1 2
1 3
1 4
2 3
6 6
1 2
2 3
3 1
4 5
5 6
6 4
2 3
1 1
1 2
1 2

output:

9
54
14

result:

ok 3 number(s): "9 54 14"

Test #2:

score: 0
Accepted
time: 7ms
memory: 7960kb

input:

5 6
5 4
1 5
3 3
5 1
5 3
2 5
5 3
4 1
1 3
4 5
5 2
3 1
2 5
5 8
4 3
5 4
2 5
3 1
5 3
1 5
2 1
5 1
5 10
4 2
5 4
4 4
2 4
3 4
2 3
4 3
1 5
2 5
5 5
5 4
2 2
3 1
4 3
1 4
5 7
4 4
5 5
4 5
1 5
5 1
5 1
2 4
5 7
5 2
5 5
1 4
1 4
4 3
2 2
2 5
5 0
5 10
4 3
5 5
4 4
5 4
4 1
4 2
4 2
5 4
5 2
1 1
5 1
5 5
5 9
3 1
4 2
5 3
4 3
1 ...

output:

14
0
0
304
1472
26
120
184
0
1152
1
736
0
1
72
0
24
736
0
68
4
464
72
336
184
6
248
44
128
312
9
4
0
0
464
44
1
68
0
42
0
272
312
6
88
6
592
768
176
0
0
64
232
0
1
0
40
736
0
0
0
140
1
896
1856
0
0
1504
38
0
1248
0
232
26
1
1824
0
0
0
0
0
0
0
592
0
4
40
304
9
1472
720
0
1
0
0
0
1
0
64
768
0
24
80
34...

result:

ok 10000 numbers

Test #3:

score: 0
Accepted
time: 10ms
memory: 7936kb

input:

10 1
4 5
10 1
8 10
10 4
4 2
9 3
2 7
8 10
10 12
3 6
1 1
3 10
9 5
10 8
9 1
10 6
10 2
9 8
9 3
7 8
4 3
10 0
10 12
3 7
7 7
4 7
7 3
9 10
2 5
3 1
3 2
5 1
9 6
6 9
3 2
10 12
10 6
2 8
7 4
6 4
4 7
9 4
1 2
10 8
8 7
4 7
6 6
5 8
10 8
7 5
10 2
1 2
7 5
3 6
6 1
8 9
5 2
10 1
3 8
10 9
4 1
5 5
9 8
6 5
8 2
3 8
10 4
1 6
...

output:

0
0
0
128
0
960
336
4
0
1
17664
0
1
0
0
5120
0
0
0
68
44
14
44544
8000
1
0
0
74
5312
12032
376
26
6
216
944
0
2208
1
36
1
164
0
3008
464
0
1
480
19840
1824
0
0
2272
0
240
0
44544
64
4
72
128
218112
18816
3616
6144
1104
0
800
6
928
0
25
0
44
816
24
400
0
0
1
31744
1
0
88064
38
42
8000
1
7872
4
2688
1...

result:

ok 10000 numbers

Test #4:

score: 0
Accepted
time: 13ms
memory: 8132kb

input:

2000 418
317 1506
1650 1676
169 1876
881 202
1095 495
672 1456
665 687
1484 115
548 1490
1651 796
147 1003
1002 487
1522 639
552 1670
515 1659
328 220
893 556
1099 147
1864 1925
1428 454
1938 365
1082 1239
829 318
1369 1386
1678 23
1857 1944
1232 27
1862 1838
1519 576
910 635
1022 833
1462 149
273 1...

output:

0
97282836
62
1
0
535582395
357330868
6
772133617
0
5423104
1
44
6582272
0
138779060
819892542
0
0
0
9
0
27169227
169547075
0
14
297811968
1
0
1
175551223
517080349
958304436
100
0
760933810
0
832583960
161536948
0
0
126621375
754917446
682475696
0
813044286
104682047
1
0
412088171
0
449674406
0
1
0...

result:

ok 100 numbers

Test #5:

score: 0
Accepted
time: 5ms
memory: 10748kb

input:

200000 23551
51427 18437
194794 188938
100711 145354
65410 46257
40174 150791
19359 151237
167481 167019
158921 57936
195000 70522
104253 7471
142739 108747
55596 86484
180132 51851
14650 6340
111995 65913
124095 134618
195417 6759
62729 57922
170869 132095
99864 86271
99706 178812
152673 40997
4851...

output:

0

result:

ok 1 number(s): "0"

Test #6:

score: 0
Accepted
time: 15ms
memory: 13556kb

input:

200000 111741
271 23182
24271 170895
179488 141529
82102 180412
177061 11230
179102 127135
161210 104638
6838 105659
75262 125436
1198 103924
123221 159361
97275 341
90341 146072
72214 96461
11865 185139
34366 20013
138849 41572
33137 92652
944 86629
65783 126563
117821 177297
119832 174994
9602 140...

output:

673749197

result:

ok 1 number(s): "673749197"

Test #7:

score: 0
Accepted
time: 7ms
memory: 11180kb

input:

200000 54109
116412 3736
86453 120149
82456 113513
33386 147272
48539 71670
106142 127226
163451 131857
78947 10277
114308 123454
41247 167672
70998 66870
171658 114198
9061 7589
121267 10773
111735 104365
120444 129600
114986 43681
27738 160086
198315 73866
23190 142664
111743 118886
86990 133182
1...

output:

0

result:

ok 1 number(s): "0"

Test #8:

score: 0
Accepted
time: 29ms
memory: 16340kb

input:

200000 142299
97960 41186
115931 45210
128529 142392
50078 81427
152721 164814
41694 127316
157180 69476
159568 57999
194571 121472
138191 31421
194584 174379
13337 52247
119269 101811
146128 100894
187414 47783
30714 71891
58418 45790
165442 162111
28390 93808
13300 15661
97154 84667
45636 124075
1...

output:

702230670

result:

ok 1 number(s): "702230670"

Test #9:

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

input:

200000 30488
46804 54443
2304 161760
7306 81671
34066 48287
56904 25253
1437 127406
192126 96695
7485 138426
99025 152194
2432 119361
142362 81889
111913 31512
29477 196032
170989 182502
87284 167009
116793 189990
34554 104795
192746 29545
25761 81046
146515 31762
115268 83152
12795 58072
117045 148...

output:

0

result:

ok 1 number(s): "0"

Test #10:

score: 0
Accepted
time: 18ms
memory: 14092kb

input:

200000 118678
138753 34997
31782 111013
77571 53654
18054 15146
161086 85693
161181 127496
185855 34314
55402 10340
146583 150212
42481 183110
90140 165206
153592 145369
115494 57549
20042 72622
154450 110427
27063 99577
145283 106903
130450 64275
88540 11387
103922 39350
76487 57445
147249 16261
11...

output:

171144475

result:

ok 1 number(s): "171144475"

Test #11:

score: 0
Accepted
time: 10ms
memory: 13316kb

input:

200000 61046
87597 72447
93963 36075
156348 82534
2042 125110
65268 154644
88221 160291
188096 28829
103319 58063
26845 13639
139426 79562
46429 72715
27975 59226
58406 151770
77607 19639
54321 29654
80438 41869
121419 109012
133562 99005
118615 31329
94032 88155
94601 190522
81704 150257
71916 4174...

output:

0

result:

ok 1 number(s): "0"

Test #12:

score: 0
Accepted
time: 8ms
memory: 13312kb

input:

200000 95057
3737 53000
90737 185328
35124 21813
186030 59265
169450 15084
47964 160381
181825 199152
142725 162681
98596 11657
3666 167503
161503 180225
69654 5787
168614 45991
69764 77055
154191 116176
23412 151456
64851 168017
95458 190630
140177 18566
27247 128448
112716 189007
48862 108446
6570...

output:

0

result:

ok 1 number(s): "0"

Test #13:

score: 0
Accepted
time: 6ms
memory: 11256kb

input:

200000 37425
185286 57746
177111 110390
105389 50692
170018 193421
73633 75524
150812 136279
184067 136771
190642 10404
178858 9675
76419 31251
109281 63542
144037 119644
111526 107508
118817 191367
54061 59594
133682 69555
40988 170126
65866 192656
170252 5804
17358 168741
73934 187492
183317 66635...

output:

9

result:

ok 1 number(s): "9"

Test #14:

score: 0
Accepted
time: 24ms
memory: 15332kb

input:

200000 132749
178140 94946
12397 154676
138172 50855
61294 84380
108097 20088
52401 199271
96989 136931
130218 5493
39015 27963
67314 59628
134297 59225
23363 163573
21265 38935
178111 46845
164752 144532
186986 113205
130174 154227
185323 122195
103076 149915
143055 51279
161584 15480
187718 66599
...

output:

945816144

result:

ok 1 number(s): "945816144"

Extra Test:

score: 0
Extra Test Passed