QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#17367#2130. Fiolki 2 [A]_silhouette_#0 1999ms31844kbC++1.8kb2022-01-06 10:07:352022-05-04 14:40:48

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-04 14:40:48]
  • 评测
  • 测评结果:0
  • 用时:1999ms
  • 内存:31844kb
  • [2022-01-06 10:07:35]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int Max_N=1e5,Max_M=1e6,Mod=(1e9)+7;
int n,m,K,Num,lin[Max_N+5],In[Max_N+5],a[55][55],f[55][Max_N+5],A[55],M[55][55],B[55],res[55];
long long ans[55];
queue<int> q;
struct Edge{
	int Id,Next;
} e[Max_M+5];
void Insert(int x,int y){
	e[++Num].Next=lin[x]; lin[x]=Num; e[Num].Id=y;
}
int Read(){
	int num=0; char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar());
	for(;ch>='0'&&ch<='9';num=num*10+ch-'0',ch=getchar());
	return num;
}
int Rand(){
	return (rand()*10000000ll+rand()*1000+rand())%(Mod-1)+1;
}
int Mul(int x,int y){
	int Ans=1;
	for(;y;y>>=1,x=1ll*x*x%Mod)
	 if(y&1) Ans=1ll*Ans*x%Mod;
	return Ans;
}
void Ins(int x){
	for(int i=0;i<K;i++) res[i]=f[i][x];
	for(int i=0;i<K;i++)
	 if(res[i]){
	 	if(!A[i]){
	 		A[i]=x;
	 		for(int j=0;j<K;j++)
			 M[i][j]=res[j];
			break;
		} else {
			if(A[i]<x){
				swap(A[i],x);
				for(int j=0;j<K;j++)
				 swap(M[i][j],res[j]);
			}
			int d=res[i]*Mul(M[i][i],Mod-2);
			for(int j=0;j<K;j++)
			 res[j]=(res[j]-1ll*d*M[i][j]%Mod+Mod)%Mod;
		}
	 }
}
int main(){
	srand(123456); 
	n=Read(),m=Read(),K=Read(); B[0]=K;
	for(int i=1;i<=m;i++){
		int u=Read(),v=Read();
		Insert(u,v); ++In[v];
	}
	for(int i=1;i<=n;i++)
	 if(!In[i]) q.push(i);
	for(;q.size();){
		int x=q.front(); q.pop();
		if(x<=K) f[x-1][x]=1;
		for(int i=lin[x];i;i=e[i].Next){
			int Rnd=Rand();
			for(int j=0;j<K;j++)
			 f[j][e[i].Id]=(1ll*f[j][e[i].Id]+1ll*f[j][x]*Rnd%Mod)%Mod;
			if(!(--In[e[i].Id])) q.push(e[i].Id);
		}
	}
	for(int x=K+1;x<=n;x++){
		Ins(x); int cnt=0;
		for(int i=0;i<K;i++) 
		 if(A[i]) B[++cnt]=A[i];
		sort(B+1,B+cnt+1);
		for(int i=1;i<=cnt;i++)
		 ans[cnt-i+1]+=B[i]-B[i-1];
		ans[0]+=x-B[cnt];
	}
	for(int i=0;i<=K;i++) printf("%lld\n",ans[i]);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 7788kb

input:

9 10 2
1 3
1 5
2 5
5 4
5 6
2 6
2 9
2 8
1 5
1 9

output:

1
8
19

result:

wrong answer 2nd lines differ - expected: '9', found: '8'

Subtask #2:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 3ms
memory: 7912kb

input:

300 1500 15
135 85
20 257
1 68
264 273
33 299
212 67
280 233
155 75
103 26
59 206
29 217
163 84
100 290
172 222
5 220
283 216
242 234
250 89
194 176
141 214
68 64
177 91
142 214
220 90
8 156
186 275
286 209
272 107
69 38
169 31
164 203
125 190
270 37
97 188
51 158
132 211
39 279
62 290
2 246
220 122...

output:

21
305
306
305
302
301
300
300
297
296
294
293
292
291
289
36563

result:

wrong answer 7th lines differ - expected: '301', found: '300'

Subtask #3:

score: 0
Wrong Answer

Test #40:

score: 0
Wrong Answer
time: 25ms
memory: 9008kb

input:

5000 15000 50
1181 1258
4643 84
55 2696
1551 4754
288 991
2926 858
4303 1448
4880 1475
1042 349
3042 628
1375 2853
1365 997
47 4335
2585 1715
4225 1987
867 1285
2144 1193
325 4578
3600 1356
3528 1711
4851 858
3205 2373
3500 801
2499 922
4780 506
587 3251
1730 664
127 2551
4346 656
3538 2694
1065 503...

output:

5460
10456
10873
10828
10800
10601
11048
10835
11097
10981
11381
10948
11414
11199
11462
11548
11499
11399
11615
11792
11762
11675
11906
12092
11816
12305
12259
12246
12571
12574
12998
13279
13433
13683
13890
15147
15601
16426
19108
20149
27579
35407
59986
95700
146511
292425
498381
669615
1941471
5...

result:

wrong answer 2nd lines differ - expected: '10468', found: '10456'

Subtask #4:

score: 0
Wrong Answer

Test #60:

score: 0
Wrong Answer
time: 396ms
memory: 15116kb

input:

50000 1000000 15
18880 16174
41509 31679
15076 47370
20331 45525
9011 10292
30074 3605
28537 9840
40932 12040
9966 39950
35297 36791
39932 38466
41304 6021
48553 3399
29042 25334
24827 41347
29537 37302
1233 15027
13100 2493
36854 26961
45936 13745
16541 43321
22862 34077
39416 3809
26911 8586
43697...

output:

5726
55737
55759
55751
55754
55823
55761
55779
55766
55793
55801
55840
55781
55807
55844
1248488383

result:

wrong answer 7th lines differ - expected: '55762', found: '55761'

Subtask #5:

score: 0
Wrong Answer

Test #81:

score: 0
Wrong Answer
time: 205ms
memory: 12392kb

input:

49999 500000 14
8451 9663
47608 35604
43707 49176
30218 12199
33000 6332
21117 37700
22586 49448
48986 4776
44551 21414
35 15791
36760 20522
39131 26292
26361 14373
25816 24129
43807 40898
9232 4733
37022 49437
48377 34456
21357 47546
19303 6932
19479 11761
45024 39091
11275 36126
30296 5456
35217 1...

output:

18779
68649
68712
68827
69000
69038
68872
69092
68986
69095
68927
69005
69230
69171
1248359722

result:

wrong answer 2nd lines differ - expected: '68650', found: '68649'

Subtask #6:

score: 0
Wrong Answer

Test #102:

score: 0
Wrong Answer
time: 888ms
memory: 20548kb

input:

70000 1000000 30
27533 9943
48960 13744
52910 60232
44875 56836
37462 15774
67781 1878
32722 69261
37166 3079
27820 54868
24963 69502
55515 34942
55875 877
33007 52281
21879 49685
69183 32992
36260 50465
38748 6864
16727 3198
27918 4429
15312 5967
69884 32618
37330 753
16587 24875
2474 7451
56404 30...

output:

14187
84260
84309
84113
84365
84201
84151
84270
84303
84172
84230
84395
84453
84211
84326
84326
84371
84212
84345
84368
84397
84311
84312
84344
84274
84346
84343
84220
84314
84351
2445476655

result:

wrong answer 4th lines differ - expected: '84114', found: '84113'

Subtask #7:

score: 0
Wrong Answer

Test #128:

score: 0
Wrong Answer
time: 461ms
memory: 17924kb

input:

69999 500000 29
60938 42787
36148 15312
17077 62566
36724 15655
25348 24373
9403 47728
18478 29610
64349 17652
40061 61284
28202 31379
33229 65668
55838 49941
20749 7682
29174 22329
4738 51379
61834 65526
51830 26697
42178 39473
15702 64077
66057 18316
50196 6614
64655 50197
60126 49955
21698 64722
...

output:

38719
109057
108590
108748
109115
109009
109214
109414
109437
109461
109384
109889
109944
109949
109843
110084
110147
109782
109892
110282
110444
110602
110500
110659
110451
110622
110709
110629
112093
2444818766

result:

wrong answer 3rd lines differ - expected: '108593', found: '108590'

Subtask #8:

score: 0
Wrong Answer

Test #154:

score: 0
Wrong Answer
time: 1999ms
memory: 31844kb

input:

100000 1000000 50
92999 77320
11746 6374
11113 48883
3765 30529
48050 41374
43964 55281
72039 28956
73896 23173
60646 84514
83912 9312
88361 68809
49972 16619
20949 36967
41288 55033
30115 57398
84781 21275
91108 64332
81204 87998
15398 70615
1116 27156
97295 12872
89612 49202
62495 32370
70840 4614...

output:

29512
129207
129531
129179
129233
129383
129483
129401
129426
129532
129449
129372
129565
129532
129559
129413
129551
129489
129625
129502
129543
129360
129562
129716
129675
129586
129472
129639
129705
129556
129685
129757
129607
129751
129429
129495
129559
129733
129638
129538
129856
129701
129767
...

result:

wrong answer 3rd lines differ - expected: '129532', found: '129531'

Subtask #9:

score: 0
Wrong Answer

Test #180:

score: 0
Wrong Answer
time: 993ms
memory: 30596kb

input:

99999 500000 49
8861 92315
18860 68957
24970 68840
31601 51945
44688 39847
79070 34993
12170 13894
75544 87259
6748 38760
98547 18652
9011 49641
40213 75883
89168 28210
62099 34092
25016 29026
10670 85648
55350 68113
3188 30844
2115 14445
765 9058
71650 23644
77821 96625
56700 12489
15671 31370
5736...

output:

117262
217073
217962
218418
218701
218837
218986
219615
219880
220636
220305
220384
220443
220086
222752
222666
222172
223077
223355
223715
223561
224183
225837
225182
226493
226323
225086
226794
225523
226309
227308
227609
228400
227981
229600
228431
230109
229011
228425
230401
229439
230799
231983...

result:

wrong answer 2nd lines differ - expected: '217079', found: '217073'

Subtask #10:

score: 0
Wrong Answer

Test #206:

score: 0
Wrong Answer
time: 403ms
memory: 27488kb

input:

99998 333333 48
73739 93660
91007 91516
66213 58419
14322 20532
23379 45804
68919 29793
96370 75509
32761 33718
67640 41557
44076 22311
98483 81319
19053 94794
53747 71410
37756 45486
80813 7949
77662 37115
50333 69157
83060 39070
40304 52327
88393 62810
45164 62483
34608 2510
86417 91245
42491 9720...

output:

392726
496758
510654
512690
524768
544852
546640
563227
575801
596018
605275
626142
637178
666337
675024
701643
742928
765062
789754
829189
873917
914811
1001651
1034157
1127267
1199008
1293917
1414209
1520745
1654124
1755379
2046031
2230475
2438684
2724332
3231373
3602735
4181929
4902264
6245652
69...

result:

wrong answer 2nd lines differ - expected: '496843', found: '496758'