QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#166529#5371. MatrixNATURAL6100 ✓222ms4308kbC++142.7kb2023-09-06 14:20:542023-09-06 14:20:54

Judging History

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

  • [2023-09-06 14:20:54]
  • 评测
  • 测评结果:100
  • 用时:222ms
  • 内存:4308kb
  • [2023-09-06 14:20:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
inline int qread()
{
	int a=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){(a*=10)+=(ch^48);ch=getchar();}
	return a*f;
}
inline void qw(int x)
{
	if(x>9)qw(x/10);
	putchar('0'+x%10);
	return ;
}
int T,n,op,A[51][51],cnt,h[51],l[51],s,t,tp;
int id,mp[2510][51],lamd[2510];
int tot,nex[6000],head[110],u[6000],to[6000],flow[6000],cur[110],gap[110],dep[110],que[110],st,ed,p,maxflow;
long long sum,S;
inline void adde(int x,int y,int val)
{
	to[++tot]=y;u[tot]=x;nex[tot]=head[x];head[x]=tot;flow[tot]=val;
	to[++tot]=x;u[tot]=y;nex[tot]=head[y];head[y]=tot;flow[tot]=0;
	return ;
}
inline void bfs()
{
	memset(dep,-1,(t+1)<<2);
	memset(gap,0,(t+1)<<2);
	que[st=ed=1]=t;++gap[dep[t]=0];
	while(st<=ed)
	{
		p=que[st++];
		for(int i=head[p];i;i=nex[i])
		{
			if(dep[to[i]]==-1)
			{
				++gap[dep[to[i]]=dep[p]+1];
				que[++ed]=to[i];
			}
		}
	}
	return ;
}
inline int dfs(int rt,int V)
{
	if(rt==t)return maxflow+=V,V;
	int an=0,cx=0;
	for(int i=cur[rt];i;i=nex[i])
	{
		cur[rt]=i;
		if(dep[to[i]]+1==dep[rt])
		{
			if(!flow[i])continue;
			cx=dfs(to[i],min(flow[i],V-an));
			if(cx)
			{
				an+=cx;
				flow[i]-=cx;
				flow[i^1]+=cx;
			}
			if(an==V)return V;
		}
	}
	--gap[dep[rt]];
	if(!gap[dep[rt]])dep[s]=t+1;
	++gap[++dep[rt]];
	return an;	
}
int main()
{
	T=qread();
	while(T--)
	{
		n=qread();sum=cnt=id=0;op=1;
		for(int i=1;i<=n;++i)for(int j=1;j<=n;++j)
		{
			A[i][j]=qread();
			if(A[i][j]<0)op=0;
		}
		for(int i=1;i<=n;++i)sum+=A[1][i];
		for(int i=2;i<=n;++i)
		{
			S=0;
			for(int j=1;j<=n;++j)S+=A[i][j];
			if(S^sum)op=0;
		}
		for(int i=1;i<=n;++i)
		{
			S=0;
			for(int j=1;j<=n;++j)S+=A[j][i];
			if(S^sum)op=0;
		}
		if(!op){puts("-1");continue;}
		for(int i=1;i<=n;++i)h[i]=++cnt;
		for(int i=1;i<=n;++i)l[i]=++cnt;
		s=++cnt;t=++cnt;
		while(1)
		{
			tot=1;maxflow=0;
			memset(head,0,(t+1)<<2);
			for(int j=1;j<=n;++j)for(int k=1;k<=n;++k)if(A[j][k])adde(h[j],l[k],1);tp=tot;
			for(int i=1;i<=n;++i)adde(s,h[i],1),adde(l[i],t,1);
			bfs();
			while(dep[s]<=t)memcpy(cur,head,(t+1)<<2),dfs(s,inf);
			if(maxflow!=n)break;++id;
			memset(mp[id],0,sizeof(mp[id]));
			maxflow=inf;p=0;
			for(int i=2;i<=tp;i+=2)
			{
				if(!flow[i])
				{
					mp[id][++p]=to[i]-n;
					maxflow=min(A[u[i]][to[i]-n],maxflow);
				}
			}
			lamd[id]=maxflow;
			for(int i=1;i<=n;++i)A[i][mp[id][i]]-=maxflow;
		}
		qw(id),puts("");
		for(int i=1;i<=id;++i)
		{
			qw(lamd[i]);putchar(' ');
			for(int j=1;j<=n;++j)qw(mp[i][j]),putchar(' ');
			puts("");
		}
	}
	return 0;	
} 

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 30
Accepted

Test #1:

score: 30
Accepted
time: 1ms
memory: 3680kb

input:

10
5
41 18467 6334 26500 2995
19169 15724 11478 29358 -21392
26962 24464 5705 28145 -30939
23281 16827 9961 491 3777
-15116 -21145 20859 -30157 99896
5
4827 5436 32391 14604 1869
3902 153 292 12382 42398
17421 18716 19718 19895 -16623
5447 21726 14771 11538 5645
27530 13096 -8045 708 25838
5
41879 4...

output:

-1
-1
17
8106 1 2 3 4 5 
23247 1 2 3 5 4 
10526 1 3 2 5 4 
10350 5 3 2 1 4 
5684 2 3 1 5 4 
2380 5 2 1 3 4 
6290 5 2 1 4 3 
29460 2 1 5 4 3 
2974 5 4 1 2 3 
16557 5 4 1 3 2 
15455 4 1 5 3 2 
27014 3 4 5 1 2 
7101 4 3 5 1 2 
3550 4 3 5 2 1 
7367 2 5 4 3 1 
6233 3 5 4 2 1 
10323 5 3 4 2 1 
-1
-1
-1
-1...

result:

ok good solution (10 test cases)

Test #2:

score: 0
Accepted
time: 1ms
memory: 3676kb

input:

10
5
59894 57729 53053 37667 58044
49556 41863 58059 44760 72149
49555 42862 54181 52697 67092
55846 40495 51765 66802 51479
51536 83438 49329 64461 17623
5
6224 11008 5844 32609 13458
14989 32702 3195 20485 -2228
3093 14343 30523 1587 19597
29314 9503 7448 25200 -2322
15523 1587 22133 -10738 40638
...

output:

17
17623 1 2 3 4 5 
24240 1 2 3 5 4 
12318 2 1 3 5 4 
14921 1 3 2 5 4 
12982 2 1 5 3 4 
24256 2 1 5 4 3 
8173 2 5 1 4 3 
3110 1 5 2 4 3 
13790 4 5 2 1 3 
13640 5 3 1 4 2 
27742 5 4 1 3 2 
17018 3 4 5 1 2 
12836 4 3 5 1 2 
12202 3 5 4 1 2 
11041 4 5 2 3 1 
23833 3 5 4 2 1 
16662 5 3 4 2 1 
-1
17
5281...

result:

ok good solution (10 test cases)

Test #3:

score: 0
Accepted
time: 1ms
memory: 3668kb

input:

10
5
10202 3625 26477 4414 17773
9314 25824 29334 25874 -27855
24372 20159 11833 28070 -21943
7487 28297 7518 8177 11012
11116 -15414 -12671 -4044 83504
5
80335 81240 95764 92557 91633
81674 87052 107785 86199 78819
83374 82671 109099 81197 85188
80115 80496 89595 108544 82779
116031 110070 39286 73...

output:

-1
17
80335 1 2 3 4 5 
6717 5 2 3 4 1 
21492 2 1 3 4 5 
1283 2 1 4 3 5 
555 2 1 3 5 4 
72477 5 3 2 1 4 
39286 2 1 4 5 3 
7638 5 3 4 1 2 
27670 4 3 1 5 2 
15268 3 1 4 5 2 
4801 5 4 1 3 2 
3790 4 1 5 3 2 
18624 2 4 5 3 1 
50903 4 5 1 3 2 
62774 3 4 5 2 1 
10194 4 5 2 3 1 
17722 3 5 4 2 1 
-1
-1
-1
17
...

result:

ok good solution (10 test cases)

Test #4:

score: 0
Accepted
time: 1ms
memory: 3676kb

input:

10
5
22335 24708 38072 45631 16687
27829 32738 19360 45510 21996
22430 32748 37233 30145 24877
38308 18739 18383 18259 53744
36531 38500 34385 7888 30129
5
44671 57452 39279 47542 49809
36827 56746 58358 41115 45707
57345 54779 56063 52429 18137
37825 52474 36230 66538 45686
62085 17302 48823 31129 ...

output:

17
18259 1 2 3 4 5 
4076 1 2 4 3 5 
10403 5 2 4 3 1 
3904 2 1 4 3 5 
6284 5 3 4 2 1 
3890 4 3 1 2 5 
7888 2 1 3 5 4 
5478 2 1 4 5 3 
10559 4 1 2 5 3 
19844 3 4 2 5 1 
7438 2 4 1 5 3 
2345 4 5 2 1 3 
2537 3 4 1 5 2 
8565 4 5 1 2 3 
15691 3 4 5 1 2 
9186 4 3 5 1 2 
11086 4 5 3 1 2 
17
44671 1 2 3 4 5 ...

result:

ok good solution (10 test cases)

Test #5:

score: 0
Accepted
time: 1ms
memory: 3692kb

input:

10
5
14423 3527 11600 26969 1588
14015 5565 28 21543 16956
25347 2088 2943 12637 15092
22409 26463 5049 4681 -495
-18087 20464 38487 -7723 24966
5
608 32060 21221 1758 18035
29954 20888 14146 690 8004
7949 12843 21430 25620 5840
748 27067 4536 20783 20548
34423 -19176 12349 24831 21255
5
64025 55878...

output:

-1
-1
17
53784 1 2 3 4 5 
10241 1 3 2 4 5 
5840 5 3 2 4 1 
10804 5 2 4 3 1 
37996 2 1 4 3 5 
52551 5 3 2 1 4 
131 4 3 2 5 1 
4843 3 1 2 5 4 
4538 3 5 1 2 4 
14995 2 1 4 5 3 
2887 2 4 1 5 3 
1564 3 4 1 5 2 
2230 4 1 5 2 3 
28141 3 4 5 2 1 
46657 4 5 1 2 3 
19607 3 4 5 1 2 
25451 4 5 1 3 2 
-1
-1
-1
1...

result:

ok good solution (10 test cases)

Test #6:

score: 0
Accepted
time: 1ms
memory: 3800kb

input:

10
5
18115 1679 17110 25898 28
23073 788 23977 18132 -3140
29956 28689 26113 10008 -31936
12941 15790 1723 21363 11013
-21255 15884 -6093 -12571 86865
5
127174 109596 107467 104281 105705
124370 103467 113729 125263 87394
128549 116691 134564 123221 51198
112072 118025 131046 104994 88086
62058 1064...

output:

-1
17
103467 1 2 3 4 5 
1527 2 1 3 4 5 
108069 2 1 4 3 5 
14774 5 1 4 3 2 
378 1 5 4 3 2 
7825 1 4 2 3 5 
952 1 4 3 2 5 
14552 1 5 3 2 4 
14066 4 5 3 2 1 
81912 5 3 2 1 4 
9019 5 4 2 1 3 
17935 3 4 2 5 1 
70151 3 4 1 5 2 
19381 3 4 5 2 1 
58398 4 5 1 2 3 
21141 4 3 5 1 2 
10676 4 3 5 2 1 
-1
-1
-1
1...

result:

ok good solution (10 test cases)

Test #7:

score: 0
Accepted
time: 1ms
memory: 3660kb

input:

10
5
18337 1278 12393 7636 25608
30714 28164 31591 19949 -45166
19135 2505 13337 10004 20271
16337 2623 28664 9970 7658
-19271 30682 -20733 17693 56881
5
118623 106427 108494 117715 101283
127994 107536 109218 123168 84626
127738 106914 105591 113982 98317
128516 118161 100285 131953 73627
49671 113...

output:

-1
17
105591 1 2 3 4 5 
13032 1 3 2 4 5 
13330 5 3 2 4 1 
1945 5 2 4 3 1 
76066 2 1 4 3 5 
65724 5 3 2 1 4 
30361 2 1 4 5 3 
5610 5 1 4 2 3 
14674 5 4 2 1 3 
154 4 1 2 5 3 
43112 3 4 1 5 2 
15803 4 1 5 2 3 
34396 3 4 5 2 1 
62352 4 5 1 2 3 
30986 3 4 5 1 2 
22274 4 5 1 3 2 
17132 4 3 5 1 2 
17
79455...

result:

ok good solution (10 test cases)

Test #8:

score: 0
Accepted
time: 1ms
memory: 3728kb

input:

10
5
32179 16595 20169 2327 25783
12042 31310 28182 11058 14461
7926 9487 1670 32528 45442
5651 2258 7213 9860 72071
39255 37403 39819 41280 -60704
5
58360 64228 60090 62746 84076
74052 61459 76336 59121 58532
70485 80483 66556 57499 54477
64875 78368 84232 74216 27809
61728 44962 42286 75918 104606...

output:

-1
17
58360 1 2 3 4 5 
3099 5 2 3 4 1 
5097 2 1 3 4 5 
7660 5 3 2 4 1 
41149 2 1 4 3 5 
64875 5 3 2 1 4 
3801 4 3 2 5 1 
4147 3 1 2 5 4 
6896 3 5 1 2 4 
16350 2 1 4 5 3 
1632 2 4 1 5 3 
8442 5 4 1 2 3 
1879 3 4 1 5 2 
7309 4 1 5 2 3 
47168 3 4 5 2 1 
8553 4 5 1 2 3 
43083 4 5 1 3 2 
-1
-1
-1
17
2210...

result:

ok good solution (10 test cases)

Test #9:

score: 0
Accepted
time: 1ms
memory: 3664kb

input:

10
5
27577 12750 14007 23729 29929
24081 2995 2678 24676 53562
27753 20899 11784 15565 31991
3093 13608 6172 11243 73876
25488 57740 73351 32779 -81366
5
10168 5055 11191 5973 15469
8922 6748 5651 10986 15549
2144 16446 31577 26517 -28828
14629 29916 5874 15791 -18354
11993 -10309 -6437 -11411 64020...

output:

-1
-1
17
33292 1 2 3 4 5 
248 5 2 3 4 1 
18463 5 2 4 3 1 
12516 2 1 4 3 5 
1093 2 1 3 5 4 
33697 5 3 2 1 4 
2794 2 3 1 5 4 
25393 2 1 4 5 3 
7097 2 4 1 5 3 
2918 5 4 1 2 3 
13093 4 1 5 2 3 
26090 3 4 5 2 1 
2169 2 4 5 1 3 
8147 3 4 5 1 2 
4777 2 4 5 3 1 
12573 4 5 1 3 2 
9295 4 3 5 1 2 
-1
-1
17
139...

result:

ok good solution (10 test cases)

Test #10:

score: 0
Accepted
time: 1ms
memory: 3676kb

input:

10
5
52175 34573 47184 34242 48829
39726 48464 56486 42655 29672
58676 54948 45757 42343 15279
45044 49757 42978 51268 27956
21382 29261 24598 46495 95267
5
115939 94609 88842 92104 98792
89855 95791 96911 101968 105761
111710 103031 92884 106351 76310
116598 114955 95676 118795 44262
56184 81900 11...

output:

17
45757 1 2 3 4 5 
5511 1 3 2 4 5 
907 1 2 4 3 5 
1800 5 2 4 3 1 
34573 2 1 4 3 5 
5063 5 1 4 3 2 
635 5 4 2 3 1 
8519 3 4 1 2 5 
41331 5 3 2 1 4 
7471 4 3 2 5 1 
2173 4 3 1 5 2 
5164 3 5 1 2 4 
18312 3 4 1 5 2 
90 4 1 5 2 3 
11476 3 4 5 2 1 
24508 4 5 1 2 3 
3713 3 4 5 1 2 
17
92884 1 2 3 4 5 
230...

result:

ok good solution (10 test cases)

Subtask #2:

score: 30
Accepted

Dependency #1:

100%
Accepted

Test #11:

score: 30
Accepted
time: 31ms
memory: 3940kb

input:

10
30
3303373 3309415 3289962 3309855 3312694 3291644 3309691 3294908 3296047 3312358 3320956 3313078 3317639 3306313 3317589 3316838 3308551 3311957 3312323 3293346 3313147 3293374 3301630 3308503 3311855 3315564 3317401 3290456 3301303 3309428
3308147 3304361 3303158 3313330 3307333 3299369 330747...

output:

842
1644184 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
1645879 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 30 29 
130 1 2 3 4 5 7 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 30 29 
1865 1 2 3 4 5 7 6 8 9 10 11 1...

result:

ok good solution (10 test cases)

Test #12:

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

input:

10
30
25858 20543 5081 5580 21407 4436 27670 29662 22863 9166 16463 29055 6598 15772 19331 1861 28300 18493 12041 30649 23644 4237 13082 7619 30667 10463 28816 32610 32042 667
12619 18413 30880 8108 31306 18847 4806 21452 13696 29571 23500 6377 10456 26535 21011 1587 6102 84 14423 7883 22313 25932 2...

output:

-1
-1
842
336133 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
2138 1 2 3 4 5 6 7 8 9 10 11 12 13 14 16 15 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
224 1 2 3 5 4 6 7 8 9 10 11 12 13 14 16 15 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
3223 1 2 3 5 4 6 7 8 9 10 11...

result:

ok good solution (10 test cases)

Test #13:

score: 0
Accepted
time: 31ms
memory: 3880kb

input:

10
30
28707 13868 14465 24416 8093 17673 21579 21031 5918 2118 16786 18578 20313 2650 17225 4826 19578 8273 30101 19104 14183 11785 20783 22729 7238 31393 32267 3468 29247 10437
10543 14647 32457 20611 10673 20997 8349 29837 13895 620 19507 32168 12447 9900 10461 433 29616 6193 11107 24350 28075 122...

output:

-1
-1
842
847296 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
848485 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 30 29 
1405 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 25 24 26 27 28 30 29 
1186 1 2 3 4 5 6 7 8 9 10...

result:

ok good solution (10 test cases)

Test #14:

score: 0
Accepted
time: 12ms
memory: 3868kb

input:

10
30
1877980 1884839 1882787 1892166 1890951 1884275 1871379 1889209 1880359 1875952 1886153 1873742 1878142 1881827 1884743 1885969 1876926 1862856 1889254 1866118 1888937 1874026 1869339 1878240 1884919 1891248 1888760 1871219 1876216 1872740
1864122 1869302 1866860 1862522 1876780 1882353 187564...

output:

842
930953 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
933508 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 30 29 
1790 1 2 3 4 5 6 7 8 9 10 11 13 12 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 30 29 
1029 1 2 3 4 5 6 7 8 9 10 11 13...

result:

ok good solution (10 test cases)

Test #15:

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

input:

10
30
16839 13517 8633 13614 10134 22456 18487 28474 24349 13661 725 9203 30073 11768 23094 32129 24571 17959 21191 30634 20521 15079 235 13147 2310 4543 10325 10372 6548 20066
31035 27316 10793 8342 3484 18838 28855 32154 21966 32646 7828 4919 3226 29816 29433 32404 2589 20840 7940 26665 24953 3052...

output:

-1
842
221214 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
1086 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 20 19 21 22 23 24 25 26 27 28 29 30 
3377 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 20 19 21 23 22 24 25 26 27 28 29 30 
222 30 2 3 4 5 6 7 8 9 10 11 1...

result:

ok good solution (10 test cases)

Test #16:

score: 0
Accepted
time: 31ms
memory: 3880kb

input:

10
30
19376 24875 436 7136 15860 6690 16841 19439 18717 25060 32008 30692 27748 16860 16892 13232 27975 9628 22979 16522 29299 6700 23057 26337 17895 6050 6264 11413 599 1746
2291 25318 15206 12238 1545 8559 2989 5016 29718 17740 10058 14175 39 10532 6365 27540 10236 18059 23353 18705 17687 25801 23...

output:

-1
842
1498827 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
1498921 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 30 29 
396 1 2 4 3 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 30 29 
619 1 2 4 3 5 6 7 8 9 10 11...

result:

ok good solution (10 test cases)

Test #17:

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

input:

10
30
10892 13184 20058 14812 27543 16465 28755 20969 9156 10257 21633 28245 8668 10484 153 32019 24280 20383 10231 6169 12452 28383 5255 23222 6692 16283 5861 8486 23669 8512
15623 16835 26212 11637 4379 29836 13375 14213 9540 31046 22960 18061 11097 14781 23403 17985 13008 20446 21172 30115 7730 3...

output:

-1
-1
841
204581 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
850 1 2 3 5 4 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
126 2 1 3 5 4 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
1440 2 1 3 5 4 6 7 8 9 10 11 ...

result:

ok good solution (10 test cases)

Test #18:

score: 0
Accepted
time: 38ms
memory: 3944kb

input:

10
30
353867 334928 355743 337736 334462 337276 345871 362849 344375 360835 335013 343263 341571 356111 359479 359116 354004 335254 340524 363907 337191 344696 350783 339559 352099 361543 355713 355284 343493 339053
340069 356765 338774 355322 356053 339296 334873 365004 354379 362105 339361 343809 ...

output:

842
333896 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
2347 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 18 17 19 20 21 22 23 24 25 26 27 28 29 30 
1973 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 18 17 19 21 20 22 23 24 25 26 27 28 29 30 
1433 1 2 3 4 5 6 7 8 9 10 11 12 1...

result:

ok good solution (10 test cases)

Test #19:

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

input:

10
30
5709452 5704663 5724623 5729417 5719012 5717741 5700474 5728774 5728826 5709004 5728123 5713004 5720585 5724565 5712061 5725452 5720374 5725736 5731570 5720547 5730454 5732248 5729841 5714100 5724849 5708509 5711844 5718107 5701573 5727506
5705929 5731041 5719133 5702414 5709374 5715159 571360...

output:

842
2849870 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
2849923 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 30 29 
545 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 25 24 26 27 28 30 29 
277 1 2 3 4 5 6 7 8 9 10 11 12...

result:

ok good solution (10 test cases)

Test #20:

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

input:

10
30
25953 10308 12139 19252 16910 9492 29364 32108 15210 31797 18930 28429 22716 17633 10315 23598 25869 24586 25781 4741 16270 5941 11632 9947 2868 7563 21715 7870 421 13190
10029 23372 25206 27991 2761 23203 2874 3830 8555 13950 24995 29191 22677 13866 8288 29900 10897 27544 20268 1895 28934 298...

output:

-1
842
182374 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
194 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 18 17 19 20 21 22 23 24 25 26 27 28 29 30 
1683 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 18 17 19 20 21 22 24 23 25 26 27 28 29 30 
2767 30 2 3 4 5 6 7 8 9 10 11 1...

result:

ok good solution (10 test cases)

Subtask #3:

score: 40
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #21:

score: 40
Accepted
time: 160ms
memory: 4296kb

input:

10
50
419554 436616 427584 414027 433924 422395 436901 424493 439408 428738 440682 431561 430102 416162 417686 442910 436427 444329 440657 419013 417681 441441 438342 434122 422169 416074 432459 428218 434310 428423 415044 415229 425844 440792 424260 423526 423737 412872 442870 444169 423786 433960 ...

output:

2402
412906 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 
188 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 25 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 
...

result:

ok good solution (10 test cases)

Test #22:

score: 0
Accepted
time: 166ms
memory: 4308kb

input:

10
50
893584 892076 893457 905314 916705 899138 904688 906790 901046 893594 911521 893478 920506 893380 911302 900111 905268 890103 910984 911352 901166 894248 910297 916376 893654 910299 898556 889782 918308 904250 907080 900576 918205 907876 913449 911968 906264 896263 901735 899692 892895 910641 ...

output:

2402
444048 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 
444308 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 50 4...

result:

ok good solution (10 test cases)

Test #23:

score: 0
Accepted
time: 162ms
memory: 4232kb

input:

10
50
23486 29609 28134 10595 26557 19436 11414 25127 32057 29024 6852 19258 14689 8198 2495 8391 6023 5749 27664 16445 8230 6350 7330 25325 2339 8177 8487 26324 11091 2289 27574 6581 28990 22726 24505 14956 8994 26690 7686 9342 13371 3143 23628 23028 30018 3638 19377 24426 20532 27055
2218 21177 77...

output:

-1
-1
2402
1489448 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 
1489536 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47...

result:

ok good solution (10 test cases)

Test #24:

score: 0
Accepted
time: 164ms
memory: 4288kb

input:

10
50
10996 18902 32589 6979 31301 19649 11828 18646 7915 16872 25518 11991 2525 6524 17917 13839 11784 12991 20261 26881 16953 9823 15858 12503 23100 2818 6204 24219 6982 26658 8810 21674 3984 19227 28725 25702 23877 12930 29359 13356 25758 17337 10115 16774 2379 32448 19838 21409 11030 11660
25678...

output:

-1
2402
390541 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 
159 2 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 5...

result:

ok good solution (10 test cases)

Test #25:

score: 0
Accepted
time: 222ms
memory: 4232kb

input:

10
50
11330 28076 18669 6622 31581 9367 8116 27182 14014 28360 18539 25965 17175 13490 1543 3526 30910 4330 24092 4758 18793 28379 3253 1219 29494 443 28547 9551 25838 10174 11323 557 14218 3465 5689 21843 24822 9705 5993 23056 1046 18885 8295 3232 519 5201 25573 2046 12455 26222
20357 24910 30201 2...

output:

-1
2402
334534 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 
426 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 27 26 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 5...

result:

ok good solution (10 test cases)

Test #26:

score: 0
Accepted
time: 113ms
memory: 4240kb

input:

10
50
31555 13006 13431 12875 32085 10200 14808 29166 22364 13874 962 22154 32443 27583 24156 23098 10605 31138 32012 20063 24739 3155 16955 5196 9902 27122 13400 20035 13344 19164 17439 7329 4142 8317 18459 15189 2137 15973 20841 5014 19278 6557 15808 5590 11018 4667 10926 28657 19009 16618
31540 1...

output:

-1
-1
-1
-1
-1
2402
904440 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 
906837 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 4...

result:

ok good solution (10 test cases)

Test #27:

score: 0
Accepted
time: 221ms
memory: 4236kb

input:

10
50
29624 7488 2066 21388 18109 16375 8405 2508 6308 2448 11876 10581 19369 31971 27525 30692 27749 6838 8756 29334 12879 28725 20549 28670 27010 27036 32588 10357 10689 15671 21434 6321 32440 652 5960 29338 25988 18903 17049 4184 17270 18358 18970 7601 14868 26918 12846 27538 31841 27426
25518 11...

output:

-1
2402
2187363 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 
2187727 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48...

result:

ok good solution (10 test cases)

Test #28:

score: 0
Accepted
time: 218ms
memory: 4244kb

input:

10
50
550703 537292 527994 521360 522463 533104 537524 524721 544587 542970 547042 525564 537900 520023 550931 537043 523176 532509 526161 525479 532925 541028 531239 543596 527075 524503 545376 528970 526573 542219 532240 542870 539953 532239 540889 537088 529640 547652 541799 522254 550104 542830 ...

output:

2402
520078 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 
358 1 2 3 4 5 6 7 9 8 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 
...

result:

ok good solution (10 test cases)

Test #29:

score: 0
Accepted
time: 106ms
memory: 4228kb

input:

10
50
370458 377258 360959 361509 367278 363730 372508 381002 376334 361610 374444 372917 388548 384964 380454 374282 369842 386925 372246 375997 359252 362655 371579 372957 371781 382743 360558 377904 377349 365545 362501 379525 381433 363634 389495 372806 387251 386447 372353 376653 363380 370444 ...

output:

2402
359265 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 
451 1 2 3 4 5 6 7 8 9 10 11 12 14 13 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 
...

result:

ok good solution (10 test cases)

Test #30:

score: 0
Accepted
time: 111ms
memory: 4244kb

input:

10
50
936 10063 1380 11699 21521 3659 30222 24609 20420 373 3076 26909 2159 16341 28164 26884 8013 7881 12480 9035 1354 22940 14374 27319 1640 32602 15844 7632 9313 29411 8492 18323 1166 12607 25524 14439 29959 21041 30722 11090 19724 30479 17638 19309 11427 7120 584 11669 24451 12473
32359 21283 47...

output:

-1
-1
-1
-1
-1
2402
644279 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 
644774 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 4...

result:

ok good solution (10 test cases)