QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#368796#7737. Extending DistanceSortingWA 25ms8344kbC++204.4kb2024-03-27 16:33:302024-03-27 16:33:31

Judging History

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

  • [2024-03-27 16:33:31]
  • 评测
  • 测评结果:WA
  • 用时:25ms
  • 内存:8344kb
  • [2024-03-27 16:33:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
int n,m;
ll k;
ll ans=0;
ll r[505][505];
int idr[505][505];
ll c[505][505];
int idc[505][505];

int ec=0;
int f[2005];ll w[2005];
int eu[2005],ev[2005];
vector<pair<int,int> >adj[505];


ll pot[505];
void add(int u,int v,ll c){
	adj[u].push_back({ec,v});
	adj[v].push_back({ec+1,u});
	w[ec/2]=c;f[ec/2]=0;
	eu[ec/2]=u;
	ev[ec/2]=v;
	ec+=2;
}
ll dist[505];
bool vis[505];
int prv[505];void iu(){
	for(int i=1; i<=n*m ;i++){
		dist[i]=1e18;
		vis[i]=false;
		prv[i]=0;
	}
	typedef pair<ll,int> pli;
	priority_queue<pli,vector<pli>,greater<pli> >pq;
	for(int i=1; i<=n ;i++){
		dist[(i-1)*m+1]=0;
		pq.push({0,(i-1)*m+1});
	}
	while(!pq.empty()){
		int x=pq.top().se;pq.pop();
		if(vis[x]) continue;
		for(auto c:adj[x]){
			int ec=c.fi/2;
			if(c.fi%2){
				ll cw=1e18;
				if(f[ec]==0) cw=w[ec];
				if(f[ec]==1) cw=-w[ec];
				if(dist[c.se]>dist[x]+cw){
					dist[c.se]=dist[x]+cw;
					prv[c.se]=c.fi;
					pq.push({dist[c.se]-pot[c.se],c.se});
				}
			}
			else{
				ll cw=1e18;
				if(f[ec]==0) cw=w[ec];
				if(f[ec]==-1) cw=-w[ec];
				if(dist[c.se]>dist[x]+cw){
					dist[c.se]=dist[x]+cw;
					prv[c.se]=c.fi;
					pq.push({dist[c.se]-pot[c.se],c.se});
				}
			}
		}
	}
	int god=m;
	for(int i=1; i<=n ;i++){
		if(dist[i*m]<dist[god]) god=i*m;
	}
	for(int i=1; i<=n*m ;i++){
		dist[i]=min(dist[i],dist[god]);
	}
	for(int i=1; i<=n*m ;i++){
		pot[i]=0;
	}
	k=dist[god]+k;
}
bool jieun(){
	for(int i=1; i<=n*m ;i++){
		dist[i]=1e18;
		vis[i]=false;
		prv[i]=0;
	}
	dist[n*m]=k;
	typedef pair<ll,int> pli;
	priority_queue<pli,vector<pli>,greater<pli> >pq;
	for(int i=1; i<=n ;i++){
		dist[(i-1)*m+1]=0;
		pq.push({0,(i-1)*m+1});
	}
	while(!pq.empty()){
		int x=pq.top().se;pq.pop();
		if(vis[x]) continue;
		for(auto c:adj[x]){
			int ec=c.fi/2;
			if(c.fi%2){
				ll cw=1e18;
				if(f[ec]==0) cw=w[ec];
				if(f[ec]==1) cw=-w[ec];
				if(dist[c.se]>dist[x]+cw){
					dist[c.se]=dist[x]+cw;
					prv[c.se]=c.fi;
					pq.push({dist[c.se]-pot[c.se],c.se});
				}
			}
			else{
				ll cw=1e18;
				if(f[ec]==0) cw=w[ec];
				if(f[ec]==-1) cw=-w[ec];
				if(dist[c.se]>dist[x]+cw){
					dist[c.se]=dist[x]+cw;
					prv[c.se]=c.fi;
					pq.push({dist[c.se]-pot[c.se],c.se});
				}
			}
		}
	}
	int god=m;
	for(int i=1; i<=n ;i++){
		if(dist[i*m]<dist[god]) god=i*m;
	}
	//cout << "outputting dist" << endl;
	for(int i=1; i<=n*m ;i++){
		dist[i]=min(dist[i],dist[god]);
		//cout << dist[i]-pot[i] << ' ' << pot[i] << endl;
	}
	ll frog=dist[god]-pot[god];
	ll aug=frog;
	//cout << "iter " << pot[god] << ' ' << dist[god] << ' ' << frog << endl;
	if(frog!=0){
		for(int e=0; e<ec/2 ;e++){
			if(f[e]!=0) continue;
			if(dist[ev[e]]!=pot[ev[e]] && dist[eu[e]]==pot[eu[e]]){
				aug=min(aug,dist[ev[e]]-pot[ev[e]]);
			}
			if(dist[eu[e]]!=pot[eu[e]] && dist[ev[e]]==pot[ev[e]]){
				aug=min(aug,dist[eu[e]]-pot[eu[e]]);
			}
		}
		
		for(int e=0; e<ec/2 ;e++){
			if(f[e]==1){
				if(dist[ev[e]]!=pot[ev[e]] && dist[eu[e]]==pot[eu[e]]){
					//cout << "Add " << eu[e] << ' ' << ev[e] << ' ' << aug << endl;
					w[e]+=aug;
				}
			}
			if(f[e]==-1){
				if(dist[eu[e]]!=pot[eu[e]] && dist[ev[e]]==pot[ev[e]]){
					//cout << "Add " << ev[e] << ' ' << eu[e] << ' ' << aug << endl;
					w[e]+=aug;
				}
			}
		}
		for(int i=1; i<=n*m ;i++){
			if(dist[i]>pot[i]) pot[i]+=aug;
		}
		return true;
	}
	
	if(dist[god]==k) return false;
	ans+=k-dist[god];
	while(god%m!=1){
		int ce=prv[god];
		god^=eu[ce/2]^ev[ce/2];
		if(ce%2) f[ce/2]--;
		else f[ce/2]++;
	}
	//for(int i=1; i<=n*m ;i++) pot[i]+=dist[i]-pot[i];
	return true;
}
void solve(){
	cin >> n >> m >> k;
	ec=0;ans=0;
	for(int i=1; i<=n*m ;i++) adj[i].clear();
	//init
	for(int i=1; i<=n ;i++){
		for(int j=1; j<m ;j++){
			cin >> r[i][j];
			idr[i][j]=ec/2;
			add((i-1)*m+j,(i-1)*m+j+1,r[i][j]);
		}
	}
	for(int i=1; i<n ;i++){
		for(int j=1; j<=m ;j++){
			cin >> c[i][j];
			idc[i][j]=ec/2;
			add((i-1)*m+j,i*m+j,c[i][j]);
		}
	}
	iu();
	while(jieun());
	cout << ans << '\n';
	for(int i=1; i<=n ;i++){
		for(int j=1; j<m ;j++){
			cout << w[idr[i][j]] << ' ';
		}
		cout << '\n';
	}
	for(int i=1; i<n ;i++){
		for(int j=1; j<=m ;j++){
			cout << w[idc[i][j]] << ' ';
		}
		cout << '\n';
	}
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	int t;cin >> t;while(t--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
3 4 6
2 1 15
7 1 9
13 3 2
3 6 1 2
5 2 15 3
3 3 3
1 1
2 2
3 3
1 1 1
2 2 2

output:

9
7 1 15 
10 1 9 
13 3 2 
3 6 1 2 
5 3 15 3 
4
4 1 
3 2 
3 3 
1 1 1 
2 2 2 

result:

ok Correct. (2 test cases)

Test #2:

score: 0
Accepted
time: 3ms
memory: 7648kb

input:

125
4 4 48
33 9 39
38 74 3
18 44 9
20 91 19
76 95 17 16
61 88 50 49
68 18 33 84
4 4 14
54 69 42
47 90 28
2 73 59
1 20 90
43 22 74 19
27 67 46 43
42 21 78 80
4 4 93
12 67 38
13 85 39
74 68 77
71 80 64
92 97 53 46
66 6 30 20
66 70 71 24
4 4 34
43 86 55
49 34 73
78 77 90
99 49 5
55 4 63 47
80 24 15 3
8...

output:

87
81 9 39 
38 74 3 
38 63 9 
20 91 19 
76 95 17 16 
61 88 50 49 
68 18 33 84 
14
54 69 42 
47 90 28 
2 73 59 
15 20 90 
43 22 74 19 
27 67 46 43 
42 21 78 80 
166
105 67 38 
80 91 39 
74 68 77 
71 80 64 
92 97 53 46 
66 6 30 20 
66 70 71 24 
34
45 86 55 
49 64 73 
78 77 90 
99 49 7 
55 4 63 47 
80 ...

result:

ok Correct. (125 test cases)

Test #3:

score: 0
Accepted
time: 4ms
memory: 7736kb

input:

80
5 5 97
10 18 14 13
17 15 16 11
15 10 14 15
12 17 12 15
12 11 15 15
19 19 13 19 19
19 17 10 10 19
12 13 18 11 20
12 17 14 13 12
5 5 65
13 15 13 20
18 19 13 20
10 19 18 17
19 19 11 14
12 18 11 10
18 14 18 19 18
20 11 17 11 17
16 13 19 18 13
16 14 17 11 18
5 5 3
15 10 10 18
17 17 17 14
13 15 15 19
1...

output:

473
105 18 14 13 
108 15 16 11 
111 10 14 15 
106 17 12 15 
109 11 15 15 
19 19 13 19 19 
19 17 10 10 19 
12 13 18 11 20 
12 17 14 13 12 
271
68 15 13 20 
64 19 13 20 
62 19 18 17 
72 19 11 14 
77 18 11 10 
18 14 18 19 18 
20 11 17 11 17 
16 13 19 18 13 
16 14 17 11 18 
3
18 10 10 18 
17 17 17 14 
1...

result:

ok Correct. (80 test cases)

Test #4:

score: 0
Accepted
time: 4ms
memory: 7716kb

input:

55
6 6 98
943830625 154853276 396311720 585129723 216006508
789713291 522861691 174874210 616414184 931597164
831871942 149821142 520941619 814161584 200419736
646044877 574761262 188910317 673355715 723256093
264106685 163628126 318085983 226850181 101764170
179381345 486537031 346100002 805792579 ...

output:

98
943830625 154853276 396311720 585129723 216006508 
789713291 522861691 174874210 616414184 931597164 
831871942 149821142 520941619 814161584 200419736 
646044877 574761262 188910317 673355715 723256093 
264106783 163628126 318085983 226850181 101764170 
179381345 486537031 346100002 805792579 50...

result:

ok Correct. (55 test cases)

Test #5:

score: 0
Accepted
time: 4ms
memory: 7740kb

input:

55
6 6 96
16739843 17336211 10384494 17185421 10646458
18552039 13790956 13642043 10307995 14193711
19297204 12810329 18681558 18724838 16636750
11505737 19658923 19307194 12241535 15070027
16123862 17524159 19471242 14316479 10954501
10604286 17691735 17352365 14092770 19909253
11761060 19372581 16...

output:

96
16739843 17336211 10384494 17185421 10646458 
18552135 13790956 13642043 10307995 14193711 
19297204 12810329 18681558 18724838 16636750 
11505737 19658923 19307194 12241535 15070027 
16123862 17524159 19471242 14316479 10954501 
10604286 17691735 17352365 14092770 19909253 
11761060 19372581 168...

result:

ok Correct. (55 test cases)

Test #6:

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

input:

40
7 7 17
27500 8466 7754 5254 45204 36821
35457 23725 45494 26962 24728 31437
46232 38720 23756 17265 21004 25959
29727 6060 23244 45236 39610 23968
17068 14954 9745 28949 20957 30885
8272 49710 28660 17038 12058 48058
10306 5065 45011 25264 25765 17423
21072 22743 17503 11324 10214 6879 22253
1729...

output:

17
27517 8466 7754 5254 45204 36821 
35457 23725 45494 26962 24728 31437 
46232 38720 23756 17265 21004 25959 
29727 6060 23244 45236 39610 23968 
17068 14954 9745 28949 20957 30885 
8272 49710 28660 17038 12058 48058 
10306 5065 45011 25264 25765 17423 
21072 22743 17503 11324 10214 6879 22253 
172...

result:

ok Correct. (40 test cases)

Test #7:

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

input:

31
8 8 84
82373 175391 615535 844446 885043 54908 235817
174599 782716 140021 505505 551220 980613 844864
490309 720051 436451 436322 357173 349094 303200
428983 865478 890817 50236 172208 96832 261006
265321 413840 490656 677420 172238 872751 182871
957260 978182 971447 603592 37811 282590 470570
1...

output:

84
82373 175391 615535 844446 885043 54908 235817 
174599 782716 140021 505505 551220 980613 844864 
490309 720051 436451 436322 357173 349094 303200 
428983 865478 890817 50236 172208 96832 261006 
265321 413840 490656 677420 172238 872751 182871 
957260 978182 971447 603592 37811 282590 470570 
13...

result:

ok Correct. (31 test cases)

Test #8:

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

input:

24
9 9 80
178 146 100 118 196 180 100 110
153 125 200 139 174 169 163 196
173 167 120 182 172 142 188 132
160 150 148 171 162 125 180 152
159 152 161 177 106 129 152 114
179 132 146 126 107 148 141 151
165 123 151 153 112 151 148 182
105 188 136 199 173 192 117 118
116 190 103 198 125 150 105 118
15...

output:

227
235 146 100 118 196 180 100 110 
153 125 200 139 174 169 163 196 
173 167 120 182 172 142 188 132 
160 150 148 171 162 125 180 152 
194 152 161 177 106 129 152 114 
234 132 146 126 107 148 141 151 
165 123 151 153 112 151 148 182 
105 188 136 199 173 192 117 118 
196 190 103 198 125 150 105 118 ...

result:

ok Correct. (24 test cases)

Test #9:

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

input:

20
10 10 91
90000001 90000000 90000001 90000000 90000001 90000000 90000000 90000001 90000000
90000001 90000001 90000001 90000001 90000000 90000001 90000001 90000001 90000001
90000001 90000001 90000001 90000000 90000000 90000000 90000001 90000000 90000000
90000000 90000001 90000001 90000001 90000000 ...

output:

886
90000091 90000000 90000001 90000000 90000001 90000000 90000000 90000001 90000000 
90000087 90000001 90000001 90000001 90000000 90000001 90000001 90000001 90000001 
90000091 90000001 90000001 90000000 90000000 90000000 90000001 90000000 90000000 
90000087 90000001 90000001 90000001 90000000 90000...

result:

ok Correct. (20 test cases)

Test #10:

score: 0
Accepted
time: 22ms
memory: 5856kb

input:

10
14 14 68
20 23 20 22 23 26 23 22 28 30 25 20 29
22 30 26 20 22 21 26 23 23 22 22 22 21
24 29 30 30 24 20 25 23 30 27 27 26 24
30 25 25 24 26 26 23 22 22 30 24 20 23
27 24 29 24 22 24 21 20 20 28 24 21 28
20 24 25 29 20 30 30 30 30 24 27 23 28
29 25 25 26 21 27 23 25 25 27 23 27 23
23 22 27 27 29 ...

output:

607
77 23 20 22 23 26 23 22 28 30 25 20 29 
74 30 29 32 22 21 27 23 23 22 22 22 21 
53 29 30 30 24 20 25 23 30 27 27 26 24 
78 25 25 24 26 26 23 22 22 30 24 20 23 
64 24 29 34 22 24 30 20 20 28 24 21 28 
48 24 25 29 20 30 30 30 30 24 27 23 28 
68 25 25 29 21 27 23 25 25 27 23 27 23 
56 22 27 27 29 3...

result:

ok Correct. (10 test cases)

Test #11:

score: 0
Accepted
time: 25ms
memory: 8016kb

input:

10
10 20 79
1001 1003 1000 1003 1001 1003 1002 1003 1001 1003 1003 1000 1001 1001 1001 1002 1002 1003 1002
1001 1003 1001 1001 1001 1000 1003 1002 1000 1002 1001 1001 1003 1000 1001 1003 1001 1001 1000
1001 1003 1000 1002 1003 1003 1003 1001 1002 1002 1000 1002 1003 1001 1003 1000 1002 1000 1002
100...

output:

732
1069 1003 1000 1003 1001 1003 1002 1003 1001 1003 1003 1000 1001 1001 1001 1002 1002 1003 1002 
1079 1003 1001 1001 1001 1000 1003 1002 1000 1002 1001 1001 1003 1000 1001 1003 1001 1001 1000 
1071 1003 1000 1002 1003 1003 1003 1001 1002 1002 1000 1002 1003 1001 1003 1000 1002 1000 1002 
1075 100...

result:

ok Correct. (10 test cases)

Test #12:

score: 0
Accepted
time: 21ms
memory: 7872kb

input:

10
20 10 21
777601561 917773453 313011120 861769383 651010533 771534309 418153755 749795307 939533489
769621271 705696594 863041783 330858635 136276987 569175453 21935211 559486868 264609946
30013079 725693020 492377730 630078388 365743281 693415122 589281054 690370363 47310510
125777481 136448711 5...

output:

21
777601561 917773453 313011120 861769383 651010533 771534309 418153755 749795307 939533489 
769621271 705696594 863041783 330858635 136276987 569175453 21935211 559486868 264609946 
30013079 725693020 492377730 630078388 365743281 693415122 589281054 690370363 47310510 
125777502 136448711 5089256...

result:

ok Correct. (10 test cases)

Test #13:

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

input:

24
6 2 37
1
1
1
1
1
1
1 1
1 1
1 1
1 1
1 1
9 18 13
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 ...

output:

222
38 
38 
38 
38 
38 
38 
1 1 
1 1 
1 1 
1 1 
1 1 
117
14 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
14 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
14 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
14 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
14 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
14 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
14 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok Correct. (24 test cases)

Test #14:

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

input:

31
9 3 33
1 5
4 5
3 4
4 2
5 3
4 3
2 5
5 5
4 3
5 1 4
2 1 2
1 5 3
5 3 2
2 3 2
3 5 3
4 4 3
1 4 2
2 3 4
3 2
5 2
1 3 5
12 6 72
2 2 1 1 5
1 2 5 1 4
5 5 1 2 3
4 1 4 4 4
1 2 2 2 5
5 5 3 5 3
2 1 1 3 5
4 1 4 2 1
4 2 1 5 3
3 3 2 4 5
5 5 2 3 3
4 3 4 5 1
3 5 5 5 1 1
5 5 3 2 5 3
5 3 1 4 3 3
5 4 5 1 3 5
2 3 3 5 4 ...

output:

284
34 5 
34 5 
35 4 
37 2 
36 3 
36 3 
34 5 
34 5 
36 3 
5 1 4 
2 1 2 
1 5 3 
5 3 2 
2 3 2 
3 5 3 
4 4 3 
1 4 2 
6
7 2 
7 2 
1 3 5 
803
73 2 1 1 5 
70 2 5 1 4 
66 5 6 2 3 
69 1 4 4 4 
68 5 2 2 5 
65 5 3 5 4 
69 4 1 3 5 
71 2 4 2 3 
71 2 1 5 3 
68 3 2 4 5 
67 5 2 4 4 
68 3 4 6 1 
3 5 5 5 1 1 
5 5 3 ...

result:

ok Correct. (31 test cases)

Test #15:

score: 0
Accepted
time: 9ms
memory: 7712kb

input:

27
14 3 50
998244355 998244354
998244353 998244355
998244355 998244354
998244353 998244353
998244353 998244354
998244353 998244354
998244355 998244353
998244354 998244354
998244355 998244354
998244354 998244354
998244355 998244355
998244354 998244355
998244354 998244355
998244354 998244353
998244354...

output:

670
998244402 998244354 
998244401 998244355 
998244402 998244354 
998244403 998244353 
998244402 998244354 
998244402 998244354 
998244403 998244353 
998244402 998244354 
998244402 998244354 
998244402 998244354 
998244401 998244355 
998244401 998244355 
998244401 998244355 
998244403 998244353 
99...

result:

ok Correct. (27 test cases)

Test #16:

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

input:

23
20 8 97
65608 5872 94352 46988 59846 12493 44992
76156 71668 37922 41038 63074 89348 52169
86215 13124 34107 56625 89609 74457 68595
4701 48937 41711 40122 4771 27822 49478
44146 33934 94003 46579 70799 92669 73897
74846 46044 73186 49298 7012 81846 33315
73703 6101 59247 53180 31956 19735 66252
...

output:

97
65608 5872 94352 46988 59846 12493 44992 
76156 71668 37922 41038 63074 89348 52169 
86215 13124 34107 56625 89609 74457 68595 
4798 48937 41711 40122 4771 27822 49478 
44146 33934 94003 46579 70799 92669 73897 
74846 46044 73186 49298 7012 81846 33315 
73703 6101 59247 53180 31956 19735 66252 
1...

result:

ok Correct. (23 test cases)

Test #17:

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

input:

19
8 19 24
902387291 907620818 994686428 993181541 945788800 985461854 930840176 976723143 978273460 908804932 947598154 948392387 906663045 945746194 935677070 906756920 944967394 995192049
971027077 958873510 947130283 938614195 938536007 978161927 948149370 943899083 936971628 979751238 924273778...

output:

24
902387315 907620818 994686428 993181541 945788800 985461854 930840176 976723143 978273460 908804932 947598154 948392387 906663045 945746194 935677070 906756920 944967394 995192049 
971027077 958873510 947130283 938614195 938536007 978161927 948149370 943899083 936971628 979751238 924273778 994846...

result:

ok Correct. (19 test cases)

Test #18:

score: 0
Accepted
time: 14ms
memory: 8220kb

input:

17
8 6 73
454 453 255 154 145
234 372 334 453 446
475 154 423 475 172
348 129 504 471 299
381 454 313 281 135
313 366 411 397 449
137 361 216 132 284
231 127 338 217 508
7722 2335 6535 3174 7625 7253
1724 4688 3487 5118 746 2569
1333 8705 5312 7854 7121 8830
1497 1091 1873 8673 7066 9654
6715 1904 6...

output:

73
454 453 255 154 145 
234 372 334 453 446 
475 154 423 475 172 
348 129 504 471 299 
381 454 313 281 135 
313 366 411 397 449 
210 361 216 132 284 
231 127 338 217 508 
7722 2335 6535 3174 7625 7253 
1724 4688 3487 5118 746 2569 
1333 8705 5312 7854 7121 8830 
1497 1091 1873 8673 7066 9654 
6715 1...

result:

ok Correct. (17 test cases)

Test #19:

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

input:

23
88 2 97
841315194
845068923
970975198
957201780
251777303
404708591
2727155
669564257
336704019
803214539
649487089
931208031
194958628
208113257
766983395
773886317
969081031
767526283
94213588
872004907
742843321
70045653
828417878
78044768
948026239
74041166
698029055
507301238
56824543
257615...

output:

97
841315194 
845068923 
970975198 
957201780 
251777303 
404708591 
2727252 
669564257 
336704019 
803214539 
649487089 
931208031 
194958628 
208113257 
766983395 
773886317 
969081031 
767526283 
94213588 
872004907 
742843321 
70045653 
828417878 
78044768 
948026239 
74041166 
698029055 
507301...

result:

ok Correct. (23 test cases)

Test #20:

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

input:

19
2 75 29
919738918 817415784 547071389 765591923 840765371 272558012 857925393 355491607 630197873 232681522 488447662 651935225 655063717 94077244 436556672 393624718 961794361 486877806 959891293 894435244 411013650 92339205 12625243 190596368 124067993 451522398 927510612 174581723 914056251 79...

output:

29
919738918 817415784 547071389 765591923 840765371 272558012 857925393 355491607 630197873 232681522 488447662 651935225 655063717 94077244 436556672 393624718 961794361 486877806 959891293 894435244 411013650 92339205 12625243 190596368 124067993 451522398 927510612 174581723 914056251 791511418 ...

result:

ok Correct. (19 test cases)

Test #21:

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

input:

1
5 6 10
1 1 1 1 100
1 1 2 100 100
100 1 1 1 100
100 100 2 1 1
100 1 1 1 1
1 100 100 100 1 100
100 100 100 2 1 100
100 1 2 100 100 100
100 1 100 100 100 1

output:

10
1 1 1 1 100 
2 1 2 100 100 
100 1 10 1 100 
100 100 2 1 1 
100 1 1 1 1 
1 100 100 100 1 100 
100 100 100 2 1 100 
100 1 2 100 100 100 
100 1 100 100 100 1 

result:

ok Correct. (1 test case)

Test #22:

score: -100
Wrong Answer
time: 1ms
memory: 7744kb

input:

2
5 6 100
1 2 1 1 100
1 1 2 100 100
100 1 1 1 100
100 100 2 1 1
100 1 1 1 1
2 100 100 100 1 100
100 100 100 2 1 100
100 1 2 100 100 100
100 1 100 100 100 2
6 5 100
1 100 100 100
100 100 2 1
100 100 2 100
100 2 100 100
1 1 100 100
100 100 100 1
2 1 100 100 100
1 1 1 100 1
1 2 2 2 1
1 100 1 1 1
100 10...

output:

119
9 2 1 1 100 
7 1 2 100 100 
101 2 91 1 100 
100 100 2 1 1 
101 9 1 1 1 
2 100 100 100 1 100 
100 100 100 2 1 100 
100 1 6 100 100 100 
100 1 100 100 100 2 
101
2 100 100 100 
100 100 5 1 
100 100 2 100 
100 2 100 100 
6 1 100 100 
100 100 100 1 
2 1 100 100 100 
1 1 1 100 1 
1 2 94 2 1 
1 100 1 ...

result:

wrong answer Jury has better answer than participant. (test case 1)