QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#259642#5261. Kolorowy wążmikefeng100 ✓323ms39120kbC++141.8kb2023-11-21 09:04:452023-11-21 09:04:46

Judging History

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

  • [2023-11-21 09:04:46]
  • 评测
  • 测评结果:100
  • 用时:323ms
  • 内存:39120kb
  • [2023-11-21 09:04:45]
  • 提交

answer

bool M1;
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<iomanip>
#include<cassert>
#include<random>
#include<cstdio>
#include<vector>
#include<bitset>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<ctime>
#include<map>
#include<set>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/hash_policy.hpp>
//#include<ext/pb_ds/priority_queue.hpp>
#define fi first
#define se second
#define LD double
#define ll long long
#define Vector Point
#define I128 __int128
#define ull unsigned ll
#define pii pair<int,int>
#define pb(x) push_back(x)
#define syt cerr<<"sytakioi\n"
#define F(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)
#define look_memory cerr<<abs(&M2-&M1)/1024.0/1024<<'\n'
#define rd_i(l,r) uniform_int_distribution<int>(l,r)(rd)
#define rd_r(l,r) uniform_real_distribution<double>(l,r)(rd)
#define look_time cerr<<(clock()-Time)*1.0/CLOCKS_PER_SEC<<'\n'
using namespace std;
//using namespace __gnu_cxx;
mt19937 rd(time(0));
const int N=2005;
int m,p,n,cnt,x=1,y=1;
int a[N][N],t[N][N];
bool M2;
int main(){
	int Time=clock();
	look_memory;
	cin.tie(nullptr)->sync_with_stdio(false);
	cin>>m>>p>>n;
	memset(a,-1,sizeof a);
	memset(t,-1,sizeof t);
	t[1][1]=0;
	F(i,1,p){
		int x,y,val;cin>>x>>y>>val;
		a[x][y]=val;
	}
	vector<int> v={0};
	F(i,1,n){
		char c;cin>>c;
		if(c=='Z'){
			int x,y;cin>>x>>y;
			if(cnt-t[x][y]<v.size()) cout<<v[v.size()-(cnt-t[x][y])-1]<<'\n';
			else cout<<"-1\n";
		}else{
			if(c=='G') --x;
			if(c=='D') ++x;
			if(c=='L') --y;
			if(c=='P') ++y;
			t[x][y]=++cnt;
			if(~a[x][y]) v.emplace_back(a[x][y]),a[x][y]=-1;
		}
	}
	look_time;
	return 0;
}

詳細信息

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 4ms
memory: 35044kb

input:

2 3 2000
2 1 2
1 2 0
2 2 3
P
D
L
Z 1 2
G
Z 2 1
P
Z 2 2
Z 2 1
D
L
Z 2 1
G
P
D
Z 1 2
L
G
P
D
Z 2 2
L
Z 2 2
Z 2 2
Z 2 1
Z 1 2
Z 2 2
G
P
D
L
G
P
D
L
G
P
Z 1 1
D
L
Z 1 1
Z 1 1
Z 1 2
G
Z 2 2
P
D
L
G
Z 1 2
Z 1 2
P
Z 1 1
D
L
Z 1 1
G
P
D
L
G
P
Z 2 1
D
L
Z 1 1
Z 2 2
G
P
D
L
G
Z 2 1
Z 1 1
Z 2 2
P
D
L
G
Z 1 1
P...

output:

0
3
0
0
2
3
2
3
3
2
0
3
3
0
0
0
0
0
0
3
0
0
0
3
3
2
0
2
0
2
3
3
0
2
0
0
2
0
2
0
0
3
0
2
3
0
0
0
2
3
3
0
0
0
2
2
0
3
2
0
0
0
0
2
2
0
2
2
2
2
3
0
3
2
3
0
2
0
3
3
0
3
2
3
0
3
3
2
0
0
2
0
0
3
0
0
0
2
2
3
3
0
3
0
2
2
0
0
2
0
3
0
0
2
3
0
2
0
2
0
0
0
2
0
2
3
0
2
0
2
3
0
2
0
2
3
2
0
2
3
2
0
0
0
2
0
0
0
0
0
...

result:

ok 700 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 35120kb

input:

20 399 2000
5 20 207
5 13 172
9 2 397
5 18 191
11 5 217
11 18 193
10 17 15
9 5 266
10 16 324
14 11 180
16 9 317
1 15 185
2 16 78
3 14 225
2 19 326
1 8 80
3 9 164
8 16 366
7 8 51
2 15 230
17 8 44
1 17 287
18 8 377
11 12 315
14 15 335
8 4 20
4 2 79
9 1 94
4 15 257
15 8 195
15 7 236
15 9 13
12 5 376
3 ...

output:

0
24
-1
24
24
248
320
-1
80
0
287
-1
393
230
326
-1
230
281
373
68
0
-1
94
323
326
225
227
105
68
160
304
310
248
323
29
-1
206
-1
208
320
273
145
320
218
281
326
160
-1
-1
58
24
47
229
29
246
87
133
129
177
31
185
97
398
85
48
180
328
315
9
25
-1
152
31
68
87
175
137
304
317
147
96
58
265
320
39
0
...

result:

ok 500 lines

Test #3:

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

input:

20 399 2000
6 5 267
11 5 142
10 3 377
10 13 286
9 7 181
20 7 373
13 11 134
6 8 154
11 13 269
12 11 135
14 2 374
6 16 44
12 15 312
18 19 36
11 12 382
20 19 310
13 12 390
6 17 39
12 9 286
18 14 40
13 16 141
4 8 194
12 10 87
4 5 239
5 1 108
17 8 167
19 19 16
20 9 341
8 15 383
7 15 160
4 14 212
15 16 28...

output:

-1
0
0
-1
0
0
0
0
0
210
210
210
0
386
0
386
210
0
386
0
0
210
210
386
0
15
0
-1
386
386
15
0
15
210
386
386
0
0
210
64
0
15
386
15
-1
210
210
0
210
386
-1
386
15
0
0
0
210
64
0
210
91
64
288
288
386
112
-1
386
175
288
91
91
91
-1
-1
64
112
0
0
15
288
331
288
64
64
288
-1
332
64
331
112
112
64
210
38...

result:

ok 1601 lines

Test #4:

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

input:

300 2000 2000
77 120 61443
259 250 88371
196 155 42599
139 153 89021
250 131 36183
276 4 40656
142 1 61936
208 109 67149
216 97 23882
175 108 30969
105 57 46184
46 271 38166
28 148 87278
47 7 43967
115 34 19608
244 155 22908
50 281 57566
160 217 78151
270 17 64550
236 174 50338
150 190 3254
85 250 7...

output:

0
0
-1
0
-1
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
0
-1
0
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
-1
-1
0
0
10995
10995
0
0
10995
0
0
0
10995
-1
10995
-1
0
10995
47013
-1
47013
10995
47013
-1
0
10995
47013
10995
10995
10995
0
0
0
10995
10995
47013
47013
41517
-1
-1
0
10995
1099...

result:

ok 500 lines

Test #5:

score: 0
Accepted
time: 0ms
memory: 35044kb

input:

300 20 2000
235 52 83799
28 125 74053
159 193 11386
131 264 80712
251 289 5656
253 1 35419
292 174 60922
115 98 23250
13 102 9431
113 55 58865
108 218 27903
129 93 43216
77 216 29787
281 182 44559
47 3 52345
195 172 38398
283 173 19841
259 152 10187
220 149 73535
253 182 9316
Z 1 1
D
Z 2 1
Z 3 1
Z 2...

output:

0
0
-1
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
0
-1
0
0
0
0
-1
0
0
0
0
-1
0
0
0
0
0
0
-1
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
-1
-1
0
0
0
0
0
0
0
0
-1
-1
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
-1
-1
0
0
0
-1
-1
-1
0
-1
0
-1
0
-1
0
0
0
0
0
0
-1
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
-1
0
...

result:

ok 1000 lines

Test #6:

score: 0
Accepted
time: 0ms
memory: 35048kb

input:

300 2000 2000
217 54 2202
26 234 59074
281 127 85940
105 158 28164
269 110 8731
102 242 61898
245 111 40408
14 262 44385
279 273 14400
172 25 80783
128 161 28050
97 55 52049
131 8 22731
160 24 30254
286 172 82565
88 195 25989
87 75 83029
193 49 17337
138 30 46246
194 42 48165
119 273 30022
51 256 38...

output:

0
0
0
0
0
-1
59026
0
0
57684
59026
57684
55
0
57684
57684
59026
59026
57684
73615
57684
0
0
-1
57684
73615
57684
-1
-1
76971
-1
-1
-1
0
-1
-1
57684
55
76971
-1
0
59026
24742
-1
59026
55
24742
-1
57684
76971
76971
24418
59026
74064
32538
55
0
59026
59026
74064
79542
76971
24418
-1
24742
73615
17583
7...

result:

ok 200 lines

Subtask #2:

score: 20
Accepted

Dependency #1:

100%
Accepted

Test #7:

score: 20
Accepted
time: 7ms
memory: 35328kb

input:

100 9999 50000
19 43 9347
64 4 518
29 100 2390
87 84 6073
23 46 7577
52 47 186
86 40 394
78 78 8523
95 40 1802
13 6 3727
26 80 7090
100 69 9645
90 46 3748
25 19 7834
96 72 4015
56 4 7318
57 42 8557
27 59 7792
54 99 1993
19 40 9374
86 29 5400
73 38 5068
1 50 6770
65 89 8835
4 35 6027
42 42 3602
98 24...

output:

8415
2508
3700
2576
2576
2785
3700
8415
2576
5765
143
3136
4623
-1
385
1673
-1
1453
-1
8185
9654
824
1453
3237
1673
9750
8123
-1
8944
1460
-1
824
6770
2785
3968
9863
-1
6210
2013
1460
6459
2785
-1
1307
9219
9079
8193
6048
8123
8273
2785
9433
6677
8310
6433
3700
8500
16
790
3382
445
9239
6245
1956
-1...

result:

ok 10000 lines

Test #8:

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

input:

200 39999 50000
40 93 38469
40 3 10906
168 36 9256
192 27 34263
115 123 22212
105 132 17909
29 95 16482
134 153 16976
101 15 5833
193 92 2009
86 190 27687
139 102 39505
56 84 24724
7 128 30370
78 129 9953
95 5 34620
95 118 22145
41 173 4666
200 156 32641
186 4 37549
130 29 7961
180 57 27729
14 105 3...

output:

0
0
33608
29475
33608
5117
-1
7483
8479
36402
25284
8479
6724
-1
26843
17839
7593
39522
28278
27704
33460
19529
4213
26058
32984
4983
29676
39042
37067
33688
1970
35534
29801
912
16127
29475
25342
11277
22397
19943
-1
-1
2852
28755
28943
27703
36914
14360
14345
37006
19756
3901
10305
-1
11281
4213
3...

result:

ok 5000 lines

Test #9:

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

input:

600 10000 50000
561 504 173737
576 181 301179
237 235 326111
439 65 75162
83 367 210063
110 145 10459
227 383 161355
394 573 173666
369 74 6452
379 561 132543
320 187 127965
528 40 349850
582 232 319991
198 11 18553
391 471 210246
163 212 185882
362 124 353745
106 175 134283
436 382 123411
222 99 11...

output:

0
-1
0
0
-1
0
-1
-1
0
0
0
0
0
0
0
-1
0
0
0
0
261633
-1
0
0
261633
0
0
261633
261633
-1
0
0
261633
-1
261633
0
0
0
0
0
155913
0
261633
0
0
0
261633
261633
-1
155913
155913
-1
155913
155913
261633
-1
-1
261633
-1
261633
261633
155913
261633
155913
155913
-1
0
261633
-1
155913
155913
230670
155913
-1
-...

result:

ok 20000 lines

Test #10:

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

input:

100 9999 50000
10 47 1622
23 52 3866
75 43 1784
81 32 3569
93 77 2474
34 53 1973
61 9 5849
9 21 5299
8 60 3751
64 2 8872
1 29 5020
70 93 9837
5 1 2449
32 36 4806
90 35 1370
68 61 2422
95 18 1390
28 47 8284
84 98 3250
92 42 3150
83 36 8241
71 65 113
84 78 9506
44 61 5994
1 11 1933
62 62 791
57 20 808...

output:

0
0
8802
6749
2126
0
8422
-1
6749
2143
5472
2296
7576
5020
6674
8029
-1
4547
0
0
6674
4304
4884
4468
5472
3237
5599
2143
474
5240
172
9797
2157
8029
5240
8422
1943
-1
1836
3237
2931
-1
4685
5721
-1
2126
4600
-1
3667
4547
-1
4468
3419
6787
1457
6674
4672
4468
6558
6481
4023
6235
-1
-1
9610
7923
4195
...

result:

ok 15000 lines

Test #11:

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

input:

800 50000 50000
449 321 324011
150 364 45500
753 255 461350
252 469 406611
407 654 323057
60 565 108778
8 67 637325
76 299 258213
342 114 69245
576 55 67018
241 541 182668
356 703 174868
571 696 219875
4 473 127058
269 209 610761
167 619 373484
571 698 507543
542 72 335411
373 119 626549
435 246 533...

output:

0
0
-1
0
153857
0
99631
153857
153857
-1
99631
0
153857
0
-1
176175
99631
153857
176175
553337
176175
176175
445896
153857
-1
627905
258030
-1
627905
242395
-1
538963
99631
445896
445896
176175
99631
176175
445896
579023
176175
242395
445896
536493
379224
-1
-1
579023
539797
126243
568129
99631
5681...

result:

ok 5000 lines

Test #12:

score: 0
Accepted
time: 23ms
memory: 35076kb

input:

800 50000 50000
257 672 498090
547 192 269078
370 52 391611
607 453 123260
343 680 253570
757 210 385472
469 31 579761
723 240 366944
584 354 114353
286 269 316429
110 665 202726
599 302 246734
474 440 263271
120 651 259428
617 661 348426
68 439 283163
47 748 386986
284 783 292638
176 687 535109
769...

output:

-1
0
160424
0
0
0
0
160424
160424
461484
0
160424
461484
160424
482761
0
482761
0
0
639559
0
362252
-1
160424
0
362252
460154
461484
228958
-1
160424
639559
639559
172019
362252
172019
-1
0
172019
590060
590060
228958
362252
228958
-1
-1
600372
-1
461484
460154
214295
639559
448616
160424
460154
448...

result:

ok 10000 lines

Subtask #3:

score: 20
Accepted

Test #13:

score: 20
Accepted
time: 83ms
memory: 35108kb

input:

200 1000 1000000
193 196 0
110 183 0
78 72 0
160 46 0
185 62 0
61 56 0
122 60 0
79 188 0
100 171 0
112 60 0
141 191 0
122 58 0
79 181 0
28 24 0
115 121 0
26 17 0
103 89 0
100 138 0
58 5 0
97 174 0
137 40 0
112 104 0
45 142 0
187 17 0
45 135 0
193 152 0
13 178 0
174 36 0
157 196 0
104 55 0
165 46 0
1...

output:

0
0
0
0
-1
0
0
0
0
-1
0
0
0
0
-1
0
0
0
0
-1
0
-1
-1
0
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
-1
0
0
0
0
-1
-1
0
0
0
0
-1
0
0
0
-1
0
0
0
0
0
0
-1
-1
0
0
0
-1
0
-1
0
0
0
0
0
-1
0
0
0
0
0
0
0
-1
-1
-1
0
0
-1
0
0
0
-1
0
0
-1
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 600000 lines

Test #14:

score: 0
Accepted
time: 28ms
memory: 35132kb

input:

800 50000 1000000
363 586 0
60 552 0
24 34 0
736 678 0
269 77 0
486 152 0
133 388 0
141 311 0
673 83 0
339 392 0
341 19 0
393 177 0
177 436 0
668 715 0
248 507 0
528 603 0
125 392 0
692 294 0
705 500 0
538 486 0
30 61 0
512 505 0
296 466 0
252 493 0
222 242 0
594 746 0
705 280 0
530 150 0
81 601 0
4...

output:

-1
0
0
-1
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
-1
-1
-1
0
0
0
0
0
0
-1
0
0
0
-1
0
0
0
-1
0
-1
0
0
0
0
0
0
0
0
0
-1
0
0
-1
0
0
0
0
0
0
0
0
-1
0
-1
0
0
0
0
0
0
-1
0
0
0
0
-1
0
0
0
0
0
0
0
-1
-1
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
-1
-1
-1
0
0
-1
0
0
0
0
0
0
0
-1
-1
0
0
0
0
0
0
0
0
0
0
0
-1
0...

result:

ok 50000 lines

Test #15:

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

input:

200 100 1000000
93 170 0
150 180 0
164 30 0
190 22 0
14 101 0
190 71 0
98 110 0
89 121 0
50 21 0
50 117 0
184 83 0
127 71 0
166 5 0
15 62 0
47 63 0
74 112 0
150 68 0
97 108 0
164 193 0
88 57 0
70 84 0
127 108 0
24 183 0
152 51 0
146 152 0
59 172 0
101 109 0
27 95 0
24 94 0
105 107 0
80 182 0
19 152 ...

output:

0
0
-1
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
-1
0
0
-1
0
0
0
0
-1
0
0
0
-1
0
0
-1
0
0
0
0
0
-1
0
0
-1
0
-1
0
-1
-1
0
-1
0
0
0
0
-1
0
0
0
0
0
0
-1
0
0
0
0
-1
0
0
-1
0
0
0
0
0
0
0
-1
-1
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
-1
0
-1
0
0
0
-1
0
0
0
0
0
0
0
-1
0
0
0
0
-1
0
0...

result:

ok 10000 lines

Test #16:

score: 0
Accepted
time: 294ms
memory: 35456kb

input:

2000 1000000 1000000
558 246 0
254 1066 0
188 545 0
1212 1235 0
1522 1792 0
1588 713 0
955 862 0
527 159 0
1323 1041 0
1699 33 0
644 1106 0
67 745 0
1804 1061 0
1501 1979 0
168 1266 0
1282 626 0
359 1509 0
1509 1983 0
585 1199 0
119 1927 0
620 802 0
391 1248 0
433 1488 0
934 1569 0
710 1290 0
336 82...

output:

0
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
-1
0
0
0
0
0
0
0
0
0
0
0
0
-1
0
-1
0
-1
0
0
0
0
-1
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
-1
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
-1
0
0
0
0
0
-1
0
0
0
-1
0
-1
0
-1
-1
-1
0
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 500000 lines

Test #17:

score: 0
Accepted
time: 225ms
memory: 35988kb

input:

2000 1000000 1000000
514 839 0
1065 1696 0
405 1204 0
385 587 0
1459 1883 0
318 1169 0
718 1289 0
1514 1195 0
928 1095 0
1380 230 0
1001 1051 0
597 800 0
1897 1916 0
1211 1725 0
788 1449 0
169 308 0
1111 1290 0
1213 545 0
1226 1303 0
692 62 0
868 1587 0
1744 521 0
754 1699 0
772 1139 0
1381 247 0
18...

output:

0
0
0
0
-1
0
0
-1
0
0
0
0
0
0
0
-1
0
0
0
-1
0
-1
-1
0
0
-1
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
-1
0
-1
0
0
0
0
0
0
-1
0
0
0
-1
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
-1
0
0
-1
0
-1
0
0
0
0
-1
0
0
0
0
0
-1
0
0
0
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
-1
-1
0
0
0
0
0
0
-1
0
...

result:

ok 100000 lines

Subtask #4:

score: 0
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #18:

score: 0
Accepted
time: 118ms
memory: 35780kb

input:

500 249999 1000000
262 478 44640
113 453 196831
215 48 63657
416 102 20881
457 395 174001
75 487 210081
181 368 129118
172 195 26953
258 290 217616
314 433 63747
216 143 82131
93 110 2594
445 414 138513
472 158 92431
253 19 68152
396 455 80646
325 369 124418
129 348 29970
30 2 29431
461 66 71594
14 ...

output:

0
0
124476
0
0
0
124476
248891
248891
77797
82700
-1
213080
57609
56664
-1
38832
248891
-1
55733
124476
82700
77797
160099
0
-1
208631
174855
-1
114838
57609
-1
213080
82700
4355
97331
196788
185247
-1
191628
160900
216923
160900
245167
248891
56664
200338
65180
125472
82700
51163
246679
245167
9733...

result:

ok 400000 lines

Test #19:

score: 0
Accepted
time: 229ms
memory: 38992kb

input:

1002 1000000 1000000
842 854 417387
718 605 264063
964 384 179534
782 835 165137
370 804 588343
253 415 963619
393 875 49212
150 4 711739
687 550 584327
621 7 2935
56 936 130269
856 546 989898
872 237 388219
524 58 696972
92 244 714113
930 70 472435
696 388 350139
642 605 186865
617 696 16371
652 69...

output:

0
0
465366
465366
-1
746942
0
-1
354152
-1
465366
348592
284816
451854
605900
-1
686371
858262
683849
254683
824930
533928
337312
962873
264231
-1
888943
1936
764556
676667
-1
605900
465366
264231
582673
347739
-1
310621
785474
255134
-1
104653
3993
957768
779563
352883
-1
650225
353107
37332
990679...

result:

ok 100000 lines

Test #20:

score: 0
Accepted
time: 228ms
memory: 39120kb

input:

1000 999999 1000000
180 997 45235
266 952 540473
776 685 776996
428 761 177382
997 171 938439
70 395 301531
195 71 619262
523 218 951285
14 130 193080
402 990 904377
212 108 273532
674 43 763998
993 160 12017
789 175 803028
209 481 57207
767 245 191296
54 164 234328
254 520 361948
682 220 996222
259...

output:

0
409162
141551
235969
756341
576359
752100
-1
79746
109693
507681
-1
542679
678272
791248
360670
13469
15257
612
-1
590018
827819
532503
-1
565244
120050
731266
104871
160893
87482
299592
590018
371427
547990
-1
79746
73604
364811
-1
301257
747455
712166
827819
836596
970301
77692
186371
793725
750...

result:

ok 100000 lines

Test #21:

score: 0
Accepted
time: 131ms
memory: 35864kb

input:

500 249999 1000000
262 314 141156
83 204 12159
207 390 51013
438 321 54988
117 242 90684
132 7 132404
314 72 36120
318 287 144829
319 208 59192
14 101 61073
302 108 187952
2 247 156389
86 432 157743
310 369 155937
81 417 231530
465 351 92961
7 402 85409
208 268 105945
95 454 200599
379 310 4823
186 ...

output:

0
138210
138210
0
65466
182199
-1
225742
50864
6197
-1
138210
44225
65466
86249
154214
86249
109942
-1
183593
57705
57705
53385
183593
207900
53385
50864
225742
173497
53385
182199
137961
199627
173497
155367
79027
65014
157768
65466
44458
225742
53110
66494
207900
100047
108061
66494
-1
86249
14538...

result:

ok 400000 lines

Test #22:

score: 0
Accepted
time: 323ms
memory: 35768kb

input:

1500 1000000 1000000
1168 1227 2168547
328 752 1253776
36 1025 448529
1328 682 2226120
821 1404 144193
464 32 1973988
849 1048 204221
295 298 2031885
1029 1358 1096846
247 673 1187946
679 795 40041
993 646 58876
940 715 5958
5 724 304002
802 715 2020806
974 67 12213
749 933 992560
11 158 541666
1370...

output:

0
0
0
414316
0
0
1307200
414316
-1
-1
-1
122984
931106
-1
931106
1307200
0
458144
1301870
0
-1
931106
122984
2079039
1904904
1492508
2079039
1415833
-1
2224
1301870
458144
1415833
-1
1307200
1301870
1415833
1376598
1304245
1492508
842922
842922
1307200
-1
1399742
1415833
458144
602740
-1
458144
8154...

result:

ok 500000 lines

Test #23:

score: 0
Accepted
time: 272ms
memory: 36900kb

input:

1500 1000000 1000000
1023 402 773967
1154 253 1841130
780 1497 1698508
1447 1052 1331355
68 722 1772787
736 916 66035
718 1264 983289
296 575 213369
816 931 270983
1164 342 1257682
899 1314 2040084
33 1182 1174582
99 1275 1216916
1015 1307 1030169
239 1125 278311
308 1086 1172461
77 1447 1848509
903...

output:

0
42876
-1
42876
42876
-1
282497
282497
1157757
1936509
625020
282497
570300
1936509
480686
1727651
1028904
-1
592056
2149078
1487848
21171
0
2121166
282497
1727651
1764625
-1
2121166
1764625
1321429
1764625
677492
2052031
1911273
1525979
1487848
1028904
-1
1272439
908779
2166434
42876
908779
-1
132...

result:

ok 200000 lines

Test #24:

score: 0
Accepted
time: 117ms
memory: 35852kb

input:

500 249999 1000000
305 436 248176
45 91 202400
286 19 115925
338 434 93515
32 482 45799
493 281 45685
353 157 234744
51 210 218557
90 398 95615
500 71 187414
383 336 172759
468 103 176981
468 181 52479
430 138 181443
41 82 10647
193 286 72653
474 256 209504
126 290 5913
347 332 188900
377 159 215668...

output:

0
0
0
0
0
0
32774
106860
-1
0
221025
-1
221025
0
28753
147062
215688
221025
11493
2432
238755
36025
194946
28753
32716
216854
70168
70168
23200
90193
-1
221025
11493
141151
36025
56498
176811
173886
109716
2432
171312
176811
144421
36237
216854
169937
-1
99049
89213
99049
101778
93846
-1
200554
2432...

result:

ok 400000 lines

Test #25:

score: 0
Accepted
time: 321ms
memory: 35396kb

input:

2000 1000000 1000000
1040 1549 1377413
1559 251 1747627
1435 615 3049463
211 1361 342921
1215 430 3333605
1485 796 1740916
471 1465 2284514
1930 113 374709
1440 160 1366
1629 1898 2688571
1755 1020 1772658
595 836 1666220
1370 1140 3786640
1489 945 3943954
185 1434 3015891
1448 784 3692969
1099 1561...

output:

0
0
0
0
0
0
0
0
2717461
2717461
2717461
2717461
0
0
2717461
-1
-1
2479632
2479632
2479632
0
3816902
-1
2479632
2218746
2218746
3816902
3598996
2218746
1819165
3816902
-1
2479632
3598996
2479632
-1
3598996
-1
3598996
2479632
2218746
-1
1004364
2479632
2479632
2202999
0
-1
3598996
3598996
-1
3816902
1...

result:

ok 500000 lines

Test #26:

score: 0
Accepted
time: 289ms
memory: 35784kb

input:

2000 1000000 1000000
1416 1361 3204969
866 1741 1189830
1361 959 3538787
1951 416 608909
1455 1776 1145031
1560 913 2901719
123 1083 3343447
1770 1008 3412863
332 1948 2642592
1876 295 3260217
78 933 2719866
491 1612 3013984
531 1503 3145432
1183 59 1547196
678 674 1931547
111 1067 2904044
1729 811 ...

output:

0
0
1987430
3554776
1987430
3554776
3554776
3554776
3554776
-1
-1
0
-1
1987430
1987430
0
1116876
-1
0
3650080
3554776
1116876
5379
-1
3650080
1525167
1525167
1525167
1987430
1480436
2903858
559060
3969401
-1
3969401
1116876
1116876
684604
383308
3554776
3917176
2581228
-1
1480436
3650080
3554776
537...

result:

ok 300000 lines

Extra Test:

score: 0
Extra Test Passed