QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#51630#4879. Standard Problemzhoukangyang#AC ✓248ms18392kbC++112.3kb2022-10-03 08:40:052022-10-03 08:40:06

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-03 08:40:06]
  • 评测
  • 测评结果:AC
  • 用时:248ms
  • 内存:18392kb
  • [2022-10-03 08:40:05]
  • 提交

answer

#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long
#define ull unsigned long long 
#define vi vector <int> 
#define sz(a) ((int) (a).size())
#define me(f, x) memset(f, x, sizeof(f))
using namespace std;
const int N = 1 << 19, mod = 998244353;
int l[N], r[N];

ll tag[N];
struct node {
	ll mx;
	int count;
	node (ll MX = 0, int C = 0) {
		mx = MX, count = C;
	}
} f[N];
node operator + (node a, node b) {
	return node(max(a.mx, b.mx), ((a.mx >= b.mx ? a.count : 0) + (a.mx <= b.mx ? b.count : 0)) % mod);
}

void upd(int x) {
	f[x] = f[x << 1] + f[x << 1 | 1];
}

void build(int x, int L, int R) {
	tag[x] = 0;
	if(L == R) {
		if(L == 1) f[x] = node(0, 1);
		else f[x] = node(-1e18, 0);
		return ;
	} 
	int mid = (L + R) >> 1; 
	build(x << 1, L, mid), build(x << 1 | 1, mid + 1, R), upd(x);
}
void ad(int x, ll w) {
	tag[x] += w, f[x].mx += w;
}
void push(int x) {
	if(tag[x]) ad(x << 1, tag[x]), ad(x << 1 | 1, tag[x]), tag[x] = 0;
}
node get(int x, int L, int R, int l, int r) {
	if(l <= L && R <= r) return f[x];
	int mid = (L + R) >> 1; push(x);
	if(l <= mid && r > mid) return get(x << 1, L, mid, l, r) + get(x << 1 | 1, mid + 1, R, l, r);
	else if(l <= mid) return get(x << 1, L, mid, l, r);
	else return get(x << 1 | 1, mid + 1, R, l, r);
} 

void add(int x, int L, int R, int l, int r, int w) {
	if(l <= L && R <= r) return ad(x, w), void();
	int mid = (L + R) >> 1; push(x); 
	if(l <= mid) add(x << 1, L, mid, l, r, w);
	if(r > mid) add(x << 1 | 1, mid + 1, R, l, r, w);
	upd(x);
} 
void mark(int x, int L, int R, int p, node w) {
	if(L == R) return f[x] = f[x] + w, void();
	int mid = (L + R) >> 1; push(x);
	p <= mid ? mark(x << 1, L, mid, p, w) : mark(x << 1 | 1, mid + 1, R, p, w); upd(x);
} 
int n, m, ql[N], qr[N], qc[N];
void Main() {
	cin >> m >> n;
	build(1, 1, n);
	L(i, 1, m) {
		cin >> ql[i] >> qr[i] >> qc[i];
		add(1, 1, n, ql[i], qr[i], qc[i]);
		if(ql[i] > 1) {
			node z = get(1, 1, n, 1, ql[i] - 1);
			z.mx += qc[i], mark(1, 1, n, ql[i], z);
		}
	}
	cout << f[1].mx << ' ' << f[1].count << '\n';
}
int main () {
	ios :: sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t;
	cin >> t;
	while(t--) Main();
	return 0;
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 7ms
memory: 11796kb

input:

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

output:

3 1
6 1

result:

ok 4 number(s): "3 1 6 1"

Test #2:

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

input:

30
3 3
1 3 1
1 3 1
1 3 1
3 3
1 2 1
1 3 1
1 3 1
3 3
2 2 1
1 3 1
1 3 1
3 3
1 3 1
1 2 1
1 3 1
3 3
2 3 1
1 2 1
1 3 1
3 3
2 2 1
1 3 1
1 3 1
3 3
2 2 1
1 2 1
1 3 1
3 3
1 3 1
2 3 1
1 3 1
3 3
2 3 1
1 3 1
2 2 1
3 3
1 2 1
1 2 1
1 2 1
3 3
1 3 1
1 3 1
1 3 1
3 3
1 3 1
1 2 1
1 3 1
3 3
2 3 1
1 2 1
1 3 1
3 3
1 3 1
1...

output:

3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
2 2
3 1
3 1
3 1
3 1
2 2
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1

result:

ok 60 numbers

Test #3:

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

input:

20
5 5
1 5 1
1 5 1
1 4 1
1 5 1
1 5 1
5 5
2 4 1
1 5 1
1 5 1
2 4 1
2 4 1
5 5
2 4 1
1 5 1
1 5 1
2 5 1
1 3 1
5 5
1 5 1
1 5 1
2 3 1
1 5 1
1 4 1
5 5
1 4 1
1 4 1
2 5 1
1 3 1
2 4 1
5 5
2 4 1
3 3 1
1 3 1
2 4 1
4 4 1
5 5
3 3 1
1 4 1
3 3 1
2 5 1
2 5 1
5 5
2 4 1
2 3 1
4 4 1
2 4 1
2 4 1
5 5
3 3 1
3 3 1
2 4 1
1 4...

output:

5 1
5 1
5 1
5 1
5 1
5 1
5 1
5 1
4 1
5 1
5 1
5 1
5 1
5 1
4 1
5 1
5 1
5 1
5 1
5 1

result:

ok 40 numbers

Test #4:

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

input:

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

output:

10 1
10 1
10 1
10 1
10 1
10 1
10 1
9 1
9 1
10 1

result:

ok 20 numbers

Test #5:

score: 0
Accepted
time: 57ms
memory: 11812kb

input:

10000
20 20
2 3 1
2 3 1
1 6 1
1 6 1
1 2 1
1 1 1
1 5 1
4 4 1
1 2 1
2 4 1
1 2 1
1 6 1
1 2 1
1 9 1
1 4 1
8 11 1
2 11 1
1 8 1
2 4 1
2 7 1
20 20
4 8 1
1 2 1
2 3 1
2 2 1
1 5 1
3 7 1
1 4 1
2 7 1
3 4 1
1 2 1
5 5 1
1 6 1
1 7 1
1 8 1
1 1 1
1 1 1
3 3 1
2 3 1
1 1 1
1 2 1
20 20
1 1 1
3 11 1
1 8 1
2 9 1
2 7 1
3 9...

output:

17 1
13 1
17 2
12 6
16 1
20 1
20 1
19 1
17 1
13 9
13 4
14 3
12 1
11 3
12 9
19 2
20 1
20 1
19 2
13 4
13 2
13 7
16 2
16 1
18 1
20 1
20 1
20 1
16 5
18 1
13 2
14 4
13 2
14 2
13 6
20 1
20 1
19 1
17 2
15 2
13 4
15 2
16 1
13 2
12 6
20 1
20 1
20 1
18 1
14 4
15 2
15 2
13 5
13 6
16 1
20 1
20 1
20 1
20 1
18 1
...

result:

ok 20000 numbers

Test #6:

score: 0
Accepted
time: 84ms
memory: 11800kb

input:

1000
200 200
1 21 1
93 108 1
52 55 1
61 67 1
1 23 1
70 72 1
1 8 1
21 78 1
1 20 1
6 31 1
71 85 1
4 57 1
9 15 1
63 101 1
48 60 1
93 100 1
55 77 1
94 96 1
59 59 1
3 4 1
6 7 1
3 21 1
14 20 1
88 93 1
46 52 1
1 29 1
1 19 1
45 46 1
3 35 1
3 16 1
79 105 1
84 104 1
16 17 1
41 48 1
4 7 1
2 48 1
101 117 1
14 7...

output:

74 24
68 16
73 12
88 12
111 2
198 1
195 1
190 3
177 2
140 9
70 140
74 14
84 4
93 32
109 14
196 3
197 4
195 1
175 1
130 28
74 124
68 6
84 2
104 8
119 2
194 2
194 2
194 1
172 6
135 4
62 360
74 36
82 180
87 6
107 4
197 2
197 1
189 2
177 2
139 2
71 8
76 20
82 8
102 2
107 208
196 2
198 1
192 3
178 3
135 ...

result:

ok 2000 numbers

Test #7:

score: 0
Accepted
time: 179ms
memory: 16188kb

input:

1
200000 70000
3758 4743 1
33161 33877 1
24037 24952 1
33131 33134 1
24741 25130 1
12964 13639 1
32062 32778 1
12046 12449 1
28229 29159 1
12021 12282 1
5329 6033 1
16581 16923 1
30368 31177 1
29343 29965 1
32647 33027 1
25775 26193 1
878 1026 1
17927 17950 1
16554 16592 1
30029 30096 1
19536 19742 ...

output:

4170 745614878

result:

ok 2 number(s): "4170 745614878"

Test #8:

score: 0
Accepted
time: 163ms
memory: 18244kb

input:

1
200000 200000
78834 78835 1
80528 80530 1
47499 47503 1
65196 65198 1
36003 36005 1
79144 79146 1
91460 91460 1
87949 87951 1
97054 97054 1
99216 99219 1
1043 1046 1
25088 25089 1
59424 59428 1
78742 78744 1
46264 46265 1
44746 44750 1
84877 84881 1
24091 24094 1
35772 35774 1
77841 77841 1
96537 ...

output:

898 862947721

result:

ok 2 number(s): "898 862947721"

Test #9:

score: 0
Accepted
time: 195ms
memory: 18204kb

input:

1
200000 200000
70228 70241 1
2243 2290 1
37711 37751 1
65609 65630 1
35069 35114 1
55461 55502 1
45322 45352 1
63193 63237 1
47993 48004 1
77797 77807 1
65933 65943 1
50756 50758 1
89846 89848 1
40757 40796 1
32542 32568 1
71472 71518 1
36752 36753 1
78477 78511 1
64720 64750 1
17369 17372 1
51635 ...

output:

958 258160284

result:

ok 2 number(s): "958 258160284"

Test #10:

score: 0
Accepted
time: 207ms
memory: 18304kb

input:

1
200000 200000
75340 75924 1
89847 90265 1
59883 60818 1
26303 26836 1
83285 84012 1
51579 51933 1
83631 83730 1
34162 35024 1
82604 83469 1
22334 22878 1
39351 40150 1
74106 74554 1
6193 6244 1
16427 16530 1
20013 20625 1
34653 35093 1
83885 84698 1
66234 67215 1
35548 36129 1
998 1540 1
86220 871...

output:

2172 380312816

result:

ok 2 number(s): "2172 380312816"

Test #11:

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

input:

1
200000 200000
1 4 1
3 4 1
1 3 1
1 2 1
4 7 1
7 10 1
6 8 1
3 6 1
7 7 1
2 3 1
6 6 1
8 10 1
4 6 1
9 11 1
2 3 1
10 14 1
6 7 1
11 11 1
19 20 1
1 5 1
8 8 1
6 9 1
2 3 1
16 19 1
18 20 1
23 27 1
6 9 1
6 10 1
30 32 1
19 23 1
17 21 1
7 9 1
15 19 1
3 5 1
1 2 1
37 38 1
14 16 1
14 16 1
26 28 1
5 9 1
34 38 1
26 2...

output:

31676 227442792

result:

ok 2 number(s): "31676 227442792"

Test #12:

score: 0
Accepted
time: 135ms
memory: 18248kb

input:

1
200000 200000
2 16 1
3 24 1
3 21 1
5 36 1
3 30 1
6 45 1
7 17 1
6 46 1
4 28 1
1 11 1
11 26 1
9 51 1
1 18 1
9 41 1
8 23 1
10 10 1
1 41 1
5 27 1
16 55 1
20 27 1
10 53 1
12 52 1
20 32 1
1 3 1
1 49 1
24 65 1
20 56 1
18 29 1
11 32 1
20 48 1
3 22 1
20 53 1
32 76 1
4 43 1
17 37 1
34 74 1
12 17 1
32 68 1
1...

output:

68340 480122735

result:

ok 2 number(s): "68340 480122735"

Test #13:

score: 0
Accepted
time: 148ms
memory: 18392kb

input:

1
200000 200000
1 105 1
3 24 1
3 742 1
3 689 1
5 445 1
5 384 1
1 796 1
3 880 1
8 984 1
4 907 1
8 79 1
12 887 1
1 731 1
8 154 1
6 745 1
6 328 1
7 487 1
7 526 1
2 819 1
6 698 1
10 464 1
13 222 1
3 885 1
10 222 1
14 627 1
20 133 1
13 600 1
22 507 1
23 342 1
14 58 1
21 546 1
27 283 1
7 720 1
22 337 1
1 ...

output:

98727 824244096

result:

ok 2 number(s): "98727 824244096"

Test #14:

score: 0
Accepted
time: 84ms
memory: 16904kb

input:

1
79364 198410
79365 79366 1
79367 79368 1
79369 79370 1
79371 79372 1
79373 79374 1
79375 79376 1
79377 79378 1
79379 79380 1
79381 79382 1
79383 79384 1
79385 79386 1
79387 79388 1
79389 79390 1
79391 79392 1
79393 79394 1
79395 79396 1
79397 79398 1
79399 79400 1
79401 79402 1
79403 79404 1
79405...

output:

39682 2

result:

ok 2 number(s): "39682 2"

Test #15:

score: 0
Accepted
time: 62ms
memory: 11912kb

input:

10000
20 20
1 20 1
1 20 1
1 17 1
1 17 1
1 18 1
2 15 1
2 18 1
3 19 1
2 20 1
1 18 1
1 20 1
2 20 1
2 16 1
4 18 1
3 20 1
1 19 1
2 20 1
1 20 1
1 19 1
1 20 1
20 20
2 16 1
6 17 1
4 19 1
4 18 1
1 19 1
1 20 1
1 18 1
2 20 1
1 14 1
1 20 1
3 18 1
1 20 1
2 20 1
1 20 1
4 15 1
2 20 1
1 20 1
3 20 1
4 20 1
1 18 1
20...

output:

20 1
20 1
20 1
20 1
20 1
19 1
19 1
19 1
18 2
18 1
20 1
20 1
20 1
20 1
20 1
20 1
18 1
18 1
17 2
17 1
20 1
20 1
20 1
19 2
20 1
20 1
19 1
18 3
16 4
16 2
20 1
20 1
20 1
20 1
20 1
20 1
20 1
17 3
19 1
18 1
20 1
20 1
20 1
20 1
20 1
18 2
20 1
16 1
16 3
18 1
20 1
20 1
20 1
20 1
18 2
20 1
20 1
19 1
18 2
19 2
...

result:

ok 20000 numbers

Test #16:

score: 0
Accepted
time: 90ms
memory: 11856kb

input:

1000
200 200
1 199 1
1 200 1
1 194 1
48 158 1
88 118 1
6 199 1
2 196 1
58 141 1
34 190 1
94 123 1
1 200 1
85 113 1
74 120 1
56 140 1
98 115 1
68 133 1
95 112 1
6 199 1
24 187 1
93 113 1
5 200 1
4 194 1
52 138 1
85 126 1
30 171 1
74 151 1
46 164 1
3 197 1
98 103 1
86 116 1
86 112 1
9 190 1
97 98 1
10...

output:

197 1
194 1
195 2
195 2
195 1
192 3
194 4
195 2
192 2
187 1
198 2
194 2
198 1
196 1
192 8
196 2
195 1
190 1
190 1
186 6
197 1
197 2
195 2
190 4
190 2
195 1
194 2
192 1
192 6
188 3
196 2
192 1
192 4
195 4
189 4
193 5
195 2
195 4
191 2
190 11
195 1
196 3
188 3
192 1
191 2
192 3
196 2
199 1
189 6
188 6...

result:

ok 2000 numbers

Test #17:

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

input:

1
200000 70000
27719 42274 1
6647 63356 1
5652 64350 1
22872 47119 1
3679 66321 1
11511 58495 1
23308 46704 1
24449 45557 1
33000 36998 1
5669 64344 1
2638 67371 1
17273 52732 1
26524 43487 1
6542 63460 1
23855 46144 1
3415 66589 1
8348 61652 1
10806 59196 1
14117 55892 1
2754 67250 1
10393 59604 1
...

output:

199993 1

result:

ok 2 number(s): "199993 1"

Test #18:

score: 0
Accepted
time: 230ms
memory: 18240kb

input:

1
200000 200000
13120 186896 1
57545 142432 1
91680 108341 1
46072 153888 1
4082 195951 1
59587 140389 1
22601 177420 1
95670 104331 1
56267 143757 1
86957 113079 1
25102 174930 1
4532 195474 1
21523 178514 1
83244 116749 1
42887 157135 1
40685 159320 1
96933 103074 1
21007 179004 1
79655 120339 1
5...

output:

199986 8

result:

ok 2 number(s): "199986 8"

Test #19:

score: 0
Accepted
time: 161ms
memory: 18392kb

input:

1
200000 200000
2 199999 1
1 200000 1
1 200000 1
5 200000 1
4 199997 1
3 199996 1
7 200000 1
7 199992 1
8 199995 1
10 199997 1
8 199995 1
13 199989 1
11 199992 1
7 199989 1
8 200000 1
8 199997 1
12 199988 1
3 199983 1
10 199985 1
10 199982 1
13 199990 1
1 199985 1
19 199992 1
10 199995 1
8 199975 1
...

output:

199985 1

result:

ok 2 number(s): "199985 1"

Test #20:

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

input:

300
1497 2969
558 2856 1
1484 1893 1
438 2226 1
1292 2738 1
397 903 1
1181 1723 1
2692 2880 1
885 2721 1
951 1346 1
937 2486 1
409 929 1
311 1817 1
458 1530 1
1058 1216 1
1056 1104 1
2484 2706 1
766 1796 1
754 1413 1
1684 2509 1
173 1090 1
580 1121 1
2047 2086 1
1586 1841 1
428 1819 1
1599 2696 1
73...

output:

816 280
1349 16248
249 2
92 600
348 48
23 1
38 2
297 40
196 16
1346 288
54 4
188 72
396 24
109 50
224 30
63 8
118 2
74 12
193 336
306 80
522 64
379 120
1672 1
515 8
256 56
565 45
64 2
73 2
616 128
178 8
4 2
64 2
732 6
21 9
120 8
334 128
15 7
170 320
31 1
302 72
464 4
50 13
717 1104
405 8
71 4
483 12...

result:

ok 600 numbers

Test #21:

score: 0
Accepted
time: 235ms
memory: 18300kb

input:

1
200000 200000
53839 55210 1
103761 171904 1
51490 64117 1
52415 59053 1
28403 81648 1
36025 96539 1
34877 167586 1
37797 192220 1
103331 198197 1
104826 194492 1
70132 87411 1
60069 142685 1
124807 162475 1
56049 120528 1
109669 121796 1
36092 179102 1
156082 170394 1
117350 157532 1
39585 145600 ...

output:

100201 402633336

result:

ok 2 number(s): "100201 402633336"

Test #22:

score: 0
Accepted
time: 49ms
memory: 16908kb

input:

1
79364 198410
158727 198410 1
158725 198410 1
158723 198410 1
158721 198410 1
158719 198410 1
158717 198410 1
158715 198410 1
158713 198410 1
158711 198410 1
158709 198410 1
158707 198410 1
158705 198410 1
158703 198410 1
158701 198410 1
158699 198410 1
158697 198410 1
158695 198410 1
158693 198410...

output:

39682 2

result:

ok 2 number(s): "39682 2"

Test #23:

score: 0
Accepted
time: 44ms
memory: 16720kb

input:

1
66666 199998
133331 199998 1
133329 199998 1
133327 199998 1
133325 199998 1
133323 199998 1
133321 199998 1
133319 199998 1
133317 199998 1
133315 199998 1
133313 199998 1
133311 199998 1
133309 199998 1
133307 199998 1
133305 199998 1
133303 199998 1
133301 199998 1
133299 199998 1
133297 199998...

output:

66666 1

result:

ok 2 number(s): "66666 1"

Test #24:

score: 0
Accepted
time: 58ms
memory: 11808kb

input:

10000
20 20
2 20 5
1 20 5
2 20 2
1 20 6
3 17 3
1 20 4
2 20 7
5 20 1
1 18 5
2 18 7
2 18 2
2 18 1
1 19 6
1 20 3
1 20 7
1 16 1
2 18 10
9 15 8
1 19 6
5 20 4
20 20
2 15 3
2 19 7
1 20 2
1 18 6
3 20 5
1 20 9
1 20 10
1 19 1
1 19 3
3 16 7
2 19 4
3 17 3
1 20 10
3 16 4
2 18 4
2 15 6
2 20 2
2 20 9
3 20 5
2 13 5...

output:

93 1
105 1
128 1
117 1
114 1
124 1
98 1
101 1
127 1
117 1
112 1
108 1
111 1
99 1
97 1
105 1
106 1
116 1
97 1
107 1
113 1
115 1
86 1
137 1
99 1
108 2
114 1
94 1
96 1
83 1
113 1
104 1
99 1
82 1
117 1
91 1
103 1
107 1
100 1
86 1
123 1
111 1
119 1
112 1
78 1
128 1
122 1
117 1
91 1
108 1
118 1
99 1
99 1
...

result:

ok 20000 numbers

Test #25:

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

input:

1000
200 200
62 139 8
89 110 10
40 183 5
59 156 10
3 189 4
75 128 4
78 125 1
5 192 9
8 195 3
32 151 3
92 99 9
65 139 1
74 119 2
12 185 6
70 143 2
3 194 5
24 174 5
80 142 6
63 144 3
71 134 10
1 200 5
85 123 1
95 126 8
112 121 8
94 111 10
92 113 1
1 199 5
57 144 9
81 122 4
52 160 5
2 200 9
60 139 10
5...

output:

1077 1
1073 1
1028 1
1048 1
1088 2
1075 1
1021 1
1008 2
1093 2
1127 1
1083 1
1104 1
1102 1
1146 1
994 1
1047 1
970 1
1089 1
1052 1
998 1
996 1
1135 1
1155 1
1158 1
1046 1
1129 1
1012 1
1080 2
990 1
1002 1
1077 1
1098 1
1089 1
995 1
1109 1
1133 1
1037 1
1108 1
1053 2
1088 1
1043 1
1153 1
1053 1
1051 ...

result:

ok 2000 numbers

Test #26:

score: 0
Accepted
time: 181ms
memory: 16240kb

input:

1
200000 70000
13421 56568 1
4349 65667 2
15557 54445 2
25559 44450 1
23675 46328 1
13772 56231 1
23551 46447 3
23209 46801 2
6747 63266 1
8699 61307 1
24946 45064 3
18881 51117 3
25923 44084 3
31091 38916 1
31929 38072 2
16293 53701 2
16194 53809 2
10662 59337 3
6960 63032 3
25829 44157 2
34484 355...

output:

400757 1

result:

ok 2 number(s): "400757 1"

Test #27:

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

input:

1
200000 200000
14346 185691 9
15513 184451 4
95019 104950 3
5289 194720 4
78689 121304 1
54194 145818 4
17594 182430 10
45423 154549 7
32203 167784 6
80570 119468 6
57035 142929 3
50995 149009 8
56869 143107 9
68883 131145 3
49209 150773 8
8768 191241 3
18033 181985 2
19511 180501 10
83354 116645 2...

output:

1101347 2

result:

ok 2 number(s): "1101347 2"

Test #28:

score: 0
Accepted
time: 179ms
memory: 18236kb

input:

1
200000 200000
1835 1860 3
72172 72215 7
80101 80110 6
19476 19513 9
93148 93242 8
46447 46522 9
35057 35071 6
66552 66630 8
83931 83967 4
8564 8567 10
20863 20946 1
39346 39441 6
25535 25599 8
12284 12309 3
9979 9999 6
99467 99549 9
22984 23004 10
1635 1665 4
72541 72615 3
99278 99346 2
50884 5091...

output:

6621 113246208

result:

ok 2 number(s): "6621 113246208"

Test #29:

score: 0
Accepted
time: 143ms
memory: 18284kb

input:

1
200000 200000
2 5 7
1 88 5
2 93 9
3 29 1
1 29 3
4 93 5
7 27 4
9 32 6
8 29 9
8 103 9
10 76 4
3 89 6
4 23 6
8 64 4
3 43 8
15 77 3
13 51 6
19 26 6
4 40 7
5 95 9
21 60 5
18 58 6
3 73 10
19 79 1
15 49 7
12 105 3
26 88 8
1 55 8
21 65 8
30 60 9
31 89 1
33 116 6
31 112 2
11 82 10
34 75 7
22 24 5
27 69 1
1...

output:

462635 711287574

result:

ok 2 number(s): "462635 711287574"

Test #30:

score: 0
Accepted
time: 101ms
memory: 11996kb

input:

300
55 318
69 305 4029
182 308 4191
40 306 2136
6 262 1542
105 128 4386
75 192 2596
131 288 3792
112 118 632
34 187 785
104 119 3567
231 253 3264
164 215 2600
82 107 4796
115 168 1140
39 165 1064
95 291 2364
184 232 49
22 264 972
4 190 4675
10 245 3304
67 183 3844
171 175 400
88 140 3296
85 130 2544...

output:

93668 1
1475675 1
1861822 1
1729524 1
1017322 1
906885 1
259697 1
585460 1
1139624 1
63824 1
1015898 1
683051 1
780407 1
555390 1
68540 1
1196528 1
1398141 1
94744 1
548364 1
667084 1
371386 2
161105 1
1292366 1
393038 1
635798 1
799982 1
113188 1
204880 1
22995 1
79812 1
223924 1
777346 1
119204 1
...

result:

ok 600 numbers

Test #31:

score: 0
Accepted
time: 248ms
memory: 18112kb

input:

1
200000 200000
54789 89627 8054928
128204 171619 8705846
111831 185204 287046
35223 98646 1902720
37958 87251 9760212
74544 85603 1537270
70376 131929 4873392
44922 170533 2705892
166191 168630 9013379
27266 128950 7524690
93950 112980 5561322
63354 106040 4891284
42904 153325 9266452
11155 35900 2...

output:

494907106860 1

result:

ok 2 number(s): "494907106860 1"

Test #32:

score: 0
Accepted
time: 40ms
memory: 16608kb

input:

1
59524 198410
158727 198410 1
158725 198410 1
158723 198410 1
158721 198410 1
158719 198410 1
158717 198410 1
158715 198410 1
158713 198410 1
158711 198410 1
158709 198410 1
158707 198410 1
158705 198410 1
158703 198410 1
158701 198410 1
158699 198410 1
158697 198410 1
158695 198410 1
158693 198410...

output:

1000019841 1

result:

ok 2 number(s): "1000019841 1"

Test #33:

score: 0
Accepted
time: 30ms
memory: 16612kb

input:

1
59524 198410
79365 79366 1
79367 79368 1
79369 79370 1
79371 79372 1
79373 79374 1
79375 79376 1
79377 79378 1
79379 79380 1
79381 79382 1
79383 79384 1
79385 79386 1
79387 79388 1
79389 79390 1
79391 79392 1
79393 79394 1
79395 79396 1
79397 79398 1
79399 79400 1
79401 79402 1
79403 79404 1
79405...

output:

1000019841 1

result:

ok 2 number(s): "1000019841 1"

Test #34:

score: 0
Accepted
time: 55ms
memory: 16816kb

input:

1
79364 198410
158727 198410 1
158725 198410 1
158723 198410 1
158721 198410 1
158719 198410 1
158717 198410 1
158715 198410 1
158713 198410 1
158711 198410 1
158709 198410 1
158707 198410 1
158705 198410 1
158703 198410 1
158701 198410 1
158699 198410 1
158697 198410 1
158695 198410 1
158693 198410...

output:

29762000000000 1

result:

ok 2 number(s): "29762000000000 1"

Test #35:

score: 0
Accepted
time: 68ms
memory: 16928kb

input:

1
79364 198410
79365 79366 1
79367 79368 1
79369 79370 1
79371 79372 1
79373 79374 1
79375 79376 1
79377 79378 1
79379 79380 1
79381 79382 1
79383 79384 1
79385 79386 1
79387 79388 1
79389 79390 1
79391 79392 1
79393 79394 1
79395 79396 1
79397 79398 1
79399 79400 1
79401 79402 1
79403 79404 1
79405...

output:

29762000000000 1

result:

ok 2 number(s): "29762000000000 1"