QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#411393#6765. Don't Really Like How The Story EndsChongQYAC ✓150ms23000kbC++232.0kb2024-05-15 12:40:132024-05-15 12:40:14

Judging History

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

  • [2024-05-15 12:40:14]
  • 评测
  • 测评结果:AC
  • 用时:150ms
  • 内存:23000kb
  • [2024-05-15 12:40:13]
  • 提交

answer

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;

const long MOD = 998244353;
const int MID = 1e5 + 10;
long arr[MID];
int N, M, n, m;
long ans;
int row[] = {1, -1, 0, 0};
int cos[] = {0, 0, 1, -1};
vector<int> list[MID];
set<int> sets[MID];
bool pool[MID];
int iq = 1;

inline void fastRead(int &x) {
    x = 0;
    char ch = getchar();
    bool neg = false;
    while (ch < '0' || ch > '9') {
        if (ch == '-') neg = true;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    if (neg) x = -x;
}

void dfs(int in) {
    if (iq > n) return;
    pool[in] = true;
    if (pool[iq]) iq++;
    for (int i : list[in]) {
        if (i < iq) continue;
        if (pool[i]) continue;
        if (i == iq) {
            dfs(i);
        } else {
            while (i >= iq && iq <= n) {
                if (i == iq) {
                    dfs(iq);
                } else {
                    ans++;
                    dfs(iq);
                }
            }
        }
    }
}

void solve() {
    fastRead(n);
    fastRead(m);
    for (int i = 0; i <= n + 1; i++) {
        list[i].clear();
        sets[i].clear();
        pool[i] = false;
    }
    for (int i = 1; i <= m; i++) {
        int a, b;
        fastRead(a);
        fastRead(b);
        if (a == b) continue;
        if (a > b) {
            list[b].push_back(a);
            sets[b].insert(a);
        } else {
            list[a].push_back(b);
            sets[a].insert(b);
        }
    }
    list[1].push_back(n + 1);
    for (int i = 1; i <= n; i++) sort(list[i].begin(), list[i].end());
    if (n == 1) {
        cout << 0 << endl;
        return;
    }
    iq = 1;
    ans = 0;
    dfs(1);
    cout << max(0L, ans) << endl;
}

int main() {
    int T;
    fastRead(T);
    while (T--) {
        solve();
    }
    return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 8168kb

input:

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

output:

0
2
1

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 63ms
memory: 8288kb

input:

117747
3 7
2 1
3 3
1 3
1 1
3 2
1 1
3 1
4 8
2 3
4 3
3 2
4 2
1 3
2 1
4 3
2 4
3 4
2 3
2 2
3 3
1 1
2 5
1 1
2 2
2 2
1 2
2 2
3 7
2 1
1 2
3 3
3 2
1 2
3 3
3 2
4 5
1 2
3 3
4 4
1 4
2 1
3 1
3 2
1 3
1 1
1 1
1 1
1 6
1 1
1 1
1 1
1 1
1 1
1 1
5 4
2 1
2 5
1 3
3 2
4 7
1 1
2 4
3 2
1 1
1 1
4 2
2 3
5 8
3 3
2 2
4 2
1 4
1...

output:

0
0
1
0
0
1
1
0
0
1
1
1
0
0
2
0
2
0
1
0
0
3
0
0
0
2
1
1
1
0
0
0
2
0
2
1
3
0
2
0
3
1
2
1
0
0
1
2
0
2
0
1
2
0
0
2
0
0
0
1
0
3
0
1
0
0
1
0
0
3
2
0
0
0
1
0
2
3
0
1
1
1
1
0
0
2
1
3
0
1
2
0
0
0
3
0
0
3
1
0
2
0
0
0
1
0
0
0
0
0
0
4
0
0
0
0
0
0
2
0
1
0
0
1
1
0
0
2
0
1
0
0
0
2
0
1
2
1
0
0
0
1
0
0
1
1
1
0
0
0
...

result:

ok 117747 lines

Test #3:

score: 0
Accepted
time: 76ms
memory: 8316kb

input:

105403
3 4
3 3
2 2
3 2
2 1
5 11
4 4
3 5
5 5
4 3
4 2
1 5
4 5
3 2
5 1
1 3
1 3
5 4
5 2
3 5
5 3
2 4
6 2
6 3
1 6
3 3
3 3
3 1
2 1
3 1
3 1
1 10
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
3 6
2 3
1 1
1 3
2 2
1 1
1 1
4 6
3 1
2 4
1 4
4 1
4 3
2 4
4 5
3 1
1 2
2 3
2 1
2 4
5 4
2 4
2 1
5 1
4 3
3 6
3 3
2 1
3 3
1 1
2 2...

output:

0
1
3
4
0
1
0
1
2
0
1
1
1
2
0
0
0
0
1
0
0
0
1
0
0
0
0
3
1
0
3
0
0
3
1
0
0
0
2
0
3
3
1
3
1
1
0
0
3
3
2
0
0
0
0
1
0
1
0
0
3
0
2
1
0
0
3
0
1
1
0
1
0
3
0
0
3
0
1
0
0
0
2
1
2
1
0
0
2
1
0
0
2
0
3
0
4
3
0
1
1
0
0
0
0
0
0
0
1
1
1
4
1
1
0
1
1
0
0
4
0
1
0
0
0
1
0
0
0
0
0
0
0
2
0
0
0
2
2
0
1
0
4
2
2
1
2
0
0
0
...

result:

ok 105403 lines

Test #4:

score: 0
Accepted
time: 51ms
memory: 8184kb

input:

95203
7 11
2 1
6 3
3 1
5 6
1 6
4 7
6 3
1 2
6 1
4 5
4 1
3 10
1 1
3 1
2 3
2 1
1 3
1 1
1 3
3 1
1 2
3 1
4 12
3 4
3 3
4 1
2 4
3 4
3 4
3 3
2 1
4 2
4 2
4 2
3 2
3 5
1 3
2 2
1 1
2 3
1 2
1 1
1 1
4 7
2 4
4 3
1 4
2 4
1 1
1 3
1 3
2 11
2 2
1 1
2 1
2 1
1 2
1 1
1 1
2 2
1 1
1 1
2 1
1 3
1 1
1 1
1 1
6 9
5 5
4 6
6 2
1 ...

output:

1
0
0
0
0
2
0
0
3
2
1
0
2
0
3
0
0
3
0
0
0
1
3
0
4
4
0
2
0
3
0
0
0
0
0
4
6
3
0
4
2
0
0
0
0
0
2
5
0
0
2
0
2
1
0
1
0
1
2
0
1
2
0
0
1
1
1
0
2
1
3
0
2
2
2
0
1
1
4
2
0
2
3
2
0
2
3
3
1
5
0
5
2
1
3
2
2
2
4
0
1
1
1
0
3
0
4
1
3
4
0
2
0
4
0
0
4
0
1
2
3
4
1
1
1
1
0
4
0
1
2
0
0
3
1
0
0
0
3
5
0
0
0
0
3
1
0
0
0
3
...

result:

ok 95203 lines

Test #5:

score: 0
Accepted
time: 61ms
memory: 8244kb

input:

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

output:

0
4
3
0
4
6
3
3
4
3
5
2
1
2
1
5
0
0
0
4
2
2
2
0
0
4
0
3
5
0
0
5
3
0
1
0
0
0
3
1
0
0
0
5
0
0
0
4
2
0
0
0
3
1
0
5
0
3
0
3
6
3
1
1
3
0
5
2
0
3
0
1
0
1
4
1
2
2
0
0
6
6
3
0
0
1
3
0
2
2
0
4
0
0
3
0
4
3
5
3
0
0
0
1
3
2
1
5
0
1
0
2
1
2
4
0
3
0
1
5
5
0
0
0
0
0
0
3
0
0
4
1
0
2
3
1
4
0
0
3
0
3
1
4
1
3
1
0
0
1
...

result:

ok 86815 lines

Test #6:

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

input:

79989
1 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
6 2
3 4
3 2
4 2
3 1
1 4
6 8
4 6
3 1
3 2
5 6
3 4
1 4
3 5
3 6
1 9
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
6 2
4 5
6 6
4 10
2 4
4 2
1 4
1 1
4 2
3 4
4 1
2 2
1 1
1 3
1 8
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
9 7
6 4
1 9
9 5
6 7
5 4
5 9
9 7
8 1
...

output:

0
3
1
2
0
0
4
2
0
5
6
2
0
7
1
1
3
3
0
4
0
4
0
0
4
7
3
3
0
0
6
5
0
1
2
2
0
4
0
0
0
4
1
3
6
4
5
0
2
1
4
1
4
2
3
3
4
3
0
1
2
6
6
1
3
5
0
2
1
4
1
3
4
0
2
0
1
3
0
4
0
0
3
0
0
4
4
0
0
0
3
0
0
0
1
6
0
6
6
0
2
3
1
0
0
1
2
2
6
6
0
3
3
1
0
1
2
0
1
0
3
0
5
3
7
0
0
4
0
1
0
4
1
2
1
0
0
0
3
0
1
5
7
5
5
3
1
0
0
0
...

result:

ok 79989 lines

Test #7:

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

input:

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

output:

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

result:

ok 74062 lines

Test #8:

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

input:

32253
19 34
7 1
6 1
2 11
16 19
10 4
16 1
2 3
16 9
10 3
10 10
16 9
9 10
16 14
14 2
11 13
18 18
9 14
3 17
5 3
12 8
14 19
13 4
13 9
18 16
12 1
12 16
19 11
8 14
14 14
14 5
5 18
12 18
12 15
2 13
16 34
7 8
5 8
15 7
2 9
16 11
3 16
14 9
5 10
15 9
9 8
13 6
3 1
6 15
11 14
15 10
15 13
13 12
15 16
10 1
16 11
6 ...

output:

13
7
0
4
6
5
1
0
7
12
13
0
1
12
9
0
7
8
8
0
13
9
14
8
9
1
6
17
3
7
0
7
0
5
0
2
8
0
0
10
12
9
8
8
3
12
8
11
2
2
0
8
12
4
3
12
2
1
15
4
0
0
4
13
12
0
0
2
0
5
15
6
12
10
3
10
8
0
16
0
7
1
6
14
16
4
12
0
0
3
17
4
0
0
3
3
0
5
11
0
3
0
7
5
11
0
0
7
1
7
2
14
10
2
0
18
14
3
7
6
14
13
12
6
2
0
13
0
0
4
17
1
...

result:

ok 32253 lines

Test #9:

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

input:

16422
38 62
13 19
7 27
10 22
6 10
28 17
35 2
34 26
6 26
9 15
19 31
35 12
8 21
16 25
38 34
19 22
15 23
21 19
25 19
9 5
29 33
6 10
10 36
17 8
23 20
36 32
34 21
23 32
15 16
10 30
11 4
2 33
32 7
13 8
29 32
14 5
20 38
6 10
16 29
2 34
12 11
2 16
36 5
14 23
2 11
11 32
11 31
34 1
27 27
27 31
33 7
25 19
2 20...

output:

33
6
22
0
12
2
19
34
24
15
28
37
14
1
3
4
12
26
16
0
34
4
32
13
26
18
17
31
0
4
22
32
1
0
29
0
36
0
16
9
28
30
16
27
26
0
14
7
22
0
15
5
22
20
16
0
12
22
19
26
14
22
28
0
3
25
23
4
29
27
6
3
26
27
3
14
33
2
12
17
15
30
26
21
10
29
30
15
0
13
0
28
30
3
11
14
0
29
8
6
24
23
13
28
17
5
30
11
0
26
5
26
...

result:

ok 16422 lines

Test #10:

score: 0
Accepted
time: 52ms
memory: 8180kb

input:

8194
63 108
17 25
57 7
56 16
2 60
56 48
7 43
54 43
48 49
4 5
17 13
44 9
3 18
26 45
47 37
60 58
12 25
9 14
6 38
5 17
54 33
49 55
56 24
31 18
52 58
13 26
10 27
58 17
59 32
12 32
2 11
49 28
22 4
29 57
11 40
27 25
18 32
19 14
11 16
19 29
49 54
8 15
21 14
2 56
37 14
11 52
14 46
34 28
3 54
14 34
54 17
5 2...

output:

53
58
13
70
0
63
64
0
53
12
34
21
33
55
54
62
18
38
1
36
40
0
47
29
47
35
60
15
33
4
53
2
5
20
71
0
0
38
0
27
51
45
8
27
64
47
17
0
29
16
55
18
49
64
15
26
33
9
77
70
45
75
56
6
74
6
14
21
39
0
35
10
29
45
9
4
3
67
56
73
43
68
16
0
69
24
3
20
51
36
38
8
54
49
50
63
29
17
1
69
0
31
56
53
0
62
67
50
1...

result:

ok 8194 lines

Test #11:

score: 0
Accepted
time: 56ms
memory: 8368kb

input:

4093
34 164
20 33
31 12
6 21
31 21
5 9
32 7
29 16
23 16
34 30
1 5
30 3
30 29
21 17
21 27
21 28
33 19
28 11
22 23
8 5
24 10
17 29
31 23
26 19
24 27
23 1
31 34
19 3
33 15
9 22
33 5
27 33
19 19
16 27
32 4
17 28
5 11
29 8
29 12
33 3
17 14
16 22
29 18
1 7
21 4
23 7
3 26
14 14
31 15
16 2
1 33
6 27
21 30
3...

output:

26
34
105
78
116
74
10
0
84
0
13
18
85
84
87
26
122
53
138
113
119
0
113
34
130
118
48
118
130
142
100
73
98
27
0
1
70
55
131
48
50
83
132
69
15
119
0
53
57
48
39
0
0
92
10
106
148
102
112
54
14
141
29
15
83
60
132
93
109
15
69
59
135
121
5
111
60
15
19
11
97
38
149
10
14
0
58
42
0
113
60
17
153
44
...

result:

ok 4093 lines

Test #12:

score: 0
Accepted
time: 63ms
memory: 8340kb

input:

2041
315 175
234 81
180 280
115 27
105 99
142 26
115 277
147 280
26 88
258 55
21 118
227 240
213 15
254 134
100 42
117 95
121 74
165 190
104 94
291 104
175 104
52 255
116 236
14 23
89 167
101 237
23 172
109 270
303 30
25 90
102 58
50 265
124 216
183 200
267 299
22 234
131 18
183 38
2 159
20 116
299 ...

output:

307
15
282
60
298
310
144
22
110
250
266
165
0
290
41
245
308
133
99
63
56
136
4
256
29
295
131
287
9
59
159
276
88
74
218
268
257
49
257
246
195
249
259
266
290
0
301
174
216
9
176
282
112
234
109
198
234
247
193
216
123
57
206
70
189
198
48
183
3
180
82
305
82
144
75
80
173
295
0
209
119
75
15
290...

result:

ok 2041 lines

Test #13:

score: 0
Accepted
time: 64ms
memory: 8324kb

input:

1137
460 304
424 252
67 46
306 437
2 332
22 85
420 452
197 221
73 250
329 313
349 295
337 190
206 327
440 199
197 288
133 35
309 200
397 277
267 255
292 295
432 347
340 124
394 159
373 370
23 329
336 240
156 240
395 33
267 150
58 12
33 274
302 257
393 447
296 34
284 112
366 404
47 126
415 266
236 93...

output:

454
308
157
152
62
49
95
371
48
565
0
492
328
0
325
198
490
191
149
0
333
377
405
135
420
380
60
465
0
414
43
71
538
83
561
425
474
471
494
492
100
310
155
335
339
172
302
308
21
412
220
554
496
529
250
548
31
126
11
416
12
554
255
76
553
2
410
14
479
1
217
110
587
344
504
410
329
148
425
109
508
33...

result:

ok 1137 lines

Test #14:

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

input:

652
170 1906
34 127
38 86
125 128
156 29
27 45
23 153
78 5
165 106
163 92
130 165
6 5
116 6
56 32
67 9
3 22
71 137
151 103
51 50
103 53
27 127
159 71
146 111
97 1
65 103
170 88
13 34
27 165
152 41
121 112
45 103
27 63
15 130
95 72
35 43
43 85
86 66
117 52
54 153
64 28
136 82
43 23
8 70
142 20
144 16...

output:

142
614
477
762
272
211
1
844
678
94
482
732
576
460
913
336
905
340
961
611
6
138
65
564
18
388
965
443
680
852
492
551
653
623
895
480
905
622
861
340
67
813
328
648
81
227
852
704
104
87
281
918
177
917
401
563
767
795
220
255
297
239
966
378
911
285
2
468
369
0
904
912
449
666
258
438
535
776
80...

result:

ok 652 lines

Test #15:

score: 0
Accepted
time: 89ms
memory: 10316kb

input:

71
6433 15466
4352 5871
2180 1276
4734 3588
5284 4840
585 1017
1093 3813
6122 4891
5191 5758
1868 1014
3962 3642
4766 3371
4489 6198
973 2020
6210 1022
2193 2064
3238 868
4430 4229
1492 2666
6288 1768
2584 4768
927 884
4648 620
4182 277
5321 5010
5227 1439
3699 4350
389 5472
4979 4661
4893 418
4853 ...

output:

6418
4244
9589
9384
4650
3461
8702
1977
6556
1980
4106
2614
7781
5014
6198
3686
9940
3507
6796
4603
4302
9157
7231
5871
795
1404
2468
8321
5439
3212
1835
2246
559
2525
8841
5528
6419
691
4707
1638
9820
5352
8456
8012
180
1742
5951
7204
1327
9091
9063
7960
7810
2193
9942
5994
2086
1703
2209
8497
2035...

result:

ok 71 lines

Test #16:

score: 0
Accepted
time: 109ms
memory: 12960kb

input:

32
2829 32606
88 652
522 1008
1411 2447
2363 1268
630 940
1946 2132
1175 2425
378 1017
2570 876
2346 1075
1792 1699
250 465
2539 977
2469 1922
1027 283
292 1446
118 786
1263 969
104 105
1548 738
2649 1114
303 2425
633 833
1046 1358
2797 51
846 1885
1415 118
2100 794
600 2210
1032 1453
2636 2007
1454...

output:

2795
7618
9289
1400
4737
1626
5799
15613
16801
19701
7551
1149
1867
12942
8249
11063
11680
18512
10995
15194
18351
14204
12720
9121
776
13167
11791
4389
796
2611
14891
11839

result:

ok 32 lines

Test #17:

score: 0
Accepted
time: 123ms
memory: 15764kb

input:

22
26521 10962
24039 2867
11784 14563
5836 257
25414 26411
20341 18994
113 22616
25448 3427
1105 15078
769 1991
3973 1859
24907 15797
9479 17398
25066 24605
4183 11157
3621 4129
12315 617
23413 22647
12551 10463
24956 7083
26493 10554
26136 21498
18143 14209
18793 8418
14385 14140
7772 220
19817 121...

output:

26511
2487
6276
9224
29415
8322
10180
15058
1204
12804
12503
17086
13254
15459
2964
18440
26141
16226
22082
22683
20916
20745

result:

ok 22 lines

Test #18:

score: 0
Accepted
time: 129ms
memory: 17820kb

input:

19
2918 28102
817 1088
2053 435
2727 241
757 2494
823 2529
2223 471
2422 1098
2031 354
1929 1178
52 1342
237 935
2259 1599
2906 938
2022 49
2781 1315
2669 1273
2316 639
2509 632
2676 2804
2764 1730
2067 599
294 1109
1988 865
1812 1333
1908 1441
1657 1273
2484 1904
700 2870
340 2038
1007 407
1944 814...

output:

2893
30063
15978
17057
6807
35006
39980
7194
8762
13211
17451
8781
24634
3349
25062
5809
33296
21221
307

result:

ok 19 lines

Test #19:

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

input:

14
28361 78944
9166 23401
19149 3685
14574 17889
20858 20753
21388 2864
21606 1214
12607 25649
23763 13936
26282 20903
24171 20863
23924 20224
366 27657
5466 16368
18548 8961
5221 2033
20346 10259
6813 18557
19314 22085
12600 24520
24849 14626
13617 22664
9687 13113
24360 17019
15064 15776
6685 2184...

output:

28349
37701
4054
31585
32262
30884
3256
23891
46087
14585
20027
23759
42856
35547

result:

ok 14 lines

Test #20:

score: 0
Accepted
time: 129ms
memory: 21676kb

input:

9
86095 79416
84511 13009
53685 11570
29295 26471
63969 3196
37176 49719
48858 17975
20376 19173
73509 74609
37138 16713
59253 70866
19610 16305
67633 33320
21118 19269
79306 22980
63351 79416
27580 20616
18800 62779
13454 21187
941 40992
30280 36048
44626 10435
4328 52182
37852 46013
77423 1236
813...

output:

86079
45720
62292
26282
46723
2828
84358
39682
99571

result:

ok 9 lines

Test #21:

score: 0
Accepted
time: 108ms
memory: 19268kb

input:

9
18500 88394
7080 3074
15677 12240
15479 7288
7398 15226
5181 5611
10455 6762
11727 8379
14056 9301
8022 13089
5178 15057
10759 47
8397 12608
3981 14940
14242 5687
3419 1268
8566 10840
11631 737
12100 18060
11913 233
17619 6829
3373 8853
14230 8205
9349 11999
7890 12266
5757 1369
4471 8680
12604 68...

output:

18486
59875
66982
75745
71027
39340
97055
30172
52626

result:

ok 9 lines

Test #22:

score: 0
Accepted
time: 83ms
memory: 19088kb

input:

11
80800 4235
19393 19025
13479 37959
42098 63983
60339 16364
76507 25604
8500 40885
4813 25930
24214 34633
45293 2896
76408 78400
61397 56312
65872 134
59219 8538
17635 15676
52937 47328
29902 45303
2955 43048
14016 77503
37892 26757
57021 55601
16817 17310
23644 27230
76324 69230
32458 62058
322 6...

output:

80793
35554
65363
63577
61624
89054
321
10306
51685
83207
64649

result:

ok 11 lines

Test #23:

score: 0
Accepted
time: 116ms
memory: 20864kb

input:

10
96127 39832
52535 35557
15603 68236
76848 1492
4537 48411
21572 20130
68449 81976
65870 27631
84961 68183
90868 63689
69414 51768
18993 79667
57655 74736
24422 8835
79961 274
16966 47960
62569 57909
58169 38526
88486 20300
31528 77125
25989 81799
23472 68621
6549 19221
20047 25166
85983 51342
845...

output:

96116
26518
48025
10810
24286
21935
47182
45374
71636
89065

result:

ok 10 lines

Test #24:

score: 0
Accepted
time: 119ms
memory: 22148kb

input:

9
36280 98417
16824 449
447 13604
21545 8947
22083 29633
27627 30854
4454 25001
30735 3587
11886 12202
26838 15459
9579 21989
35090 1770
2425 28855
21456 7438
13441 23067
7253 10252
11551 14749
27238 1524
27789 13096
22054 720
33751 10090
4116 27033
13550 22283
13298 26162
26557 9634
22935 20571
298...

output:

36267
65181
83992
28476
98881
19633
17188
39785
67557

result:

ok 9 lines

Test #25:

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

input:

9
93058 38117
58505 31644
18327 29110
71127 57822
79902 60450
4535 77618
71789 23645
79527 78199
157 57279
65946 61907
70050 53744
5980 38927
84120 40874
15866 65483
89964 78682
42295 43432
50092 38156
54757 78942
18958 70543
90931 88575
28875 17984
42181 42422
53106 61146
27250 51483
19768 79956
19...

output:

93042
77317
23820
41788
42668
6198
94201
13975
55794

result:

ok 9 lines

Test #26:

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

input:

9
79633 23742
71366 64135
11591 5422
43610 72271
50384 26729
36461 68906
33698 46516
30094 50814
12874 57538
66686 12077
72466 9586
61404 53230
37526 14380
70142 626
9393 5549
68905 31817
63957 23819
31922 513
49864 26514
9853 19757
62564 41309
40458 76684
60105 55964
19174 65651
75981 31573
52139 7...

output:

79620
50504
99640
80459
6634
51028
539
56189
87400

result:

ok 9 lines

Test #27:

score: 0
Accepted
time: 61ms
memory: 18188kb

input:

11
48097 12689
41135 36896
37131 39705
8468 32391
37839 16063
17263 31304
12559 2751
11134 10385
15414 25061
29830 33535
30894 24529
3784 6442
22008 190
42742 43400
25750 9477
27870 18588
33959 22164
30293 39487
8769 1621
21072 39687
46120 24979
36889 3674
44714 21173
41540 13629
36194 28336
45754 3...

output:

48088
77064
25178
43374
71133
92707
97983
10755
97710
19893
91659

result:

ok 11 lines

Test #28:

score: 0
Accepted
time: 115ms
memory: 19596kb

input:

11
1601 17204
321 367
1278 102
276 1467
977 1166
480 1426
18 1096
1409 1480
175 79
319 1212
660 592
362 1465
1059 1125
994 69
1455 1549
944 800
139 1599
270 841
1291 1447
163 353
1561 775
103 175
288 1400
1342 1191
1211 758
134 523
20 1513
729 1189
921 849
809 308
605 1323
413 1574
620 1248
1175 715...

output:

1579
55749
42512
59929
15854
38126
48022
4471
89933
74472
78489

result:

ok 11 lines

Test #29:

score: 0
Accepted
time: 150ms
memory: 21236kb

input:

11
31582 23151
6973 25199
30380 528
3824 27006
6068 19631
20920 20098
7538 2660
3885 31459
21918 27552
16589 27847
8275 12589
5440 7159
12100 30729
17160 24118
19071 14859
7513 31049
12643 16432
8651 13995
12412 29101
17323 3828
10986 4615
28 5230
7815 29896
12700 10249
9503 23064
30622 19421
231 53...

output:

31573
14478
76822
96802
9050
66290
33025
9680
12295
26807
15688

result:

ok 11 lines

Test #30:

score: 0
Accepted
time: 81ms
memory: 19776kb

input:

13
13036 23902
8577 3346
2519 8542
9264 10729
5516 11404
2702 1853
4740 9863
2172 5103
5450 1894
11422 4948
851 1072
7768 4001
6935 3370
10588 166
12915 2350
8485 9458
6532 12017
2226 49
2151 7183
3853 12567
715 7230
9136 2842
10190 6398
4296 4759
352 3343
10812 1649
3223 3117
8194 8633
2273 7164
12...

output:

13025
71461
98721
22903
5975
25984
11328
56437
78297
42059
63114
63977
86796

result:

ok 13 lines

Test #31:

score: 0
Accepted
time: 140ms
memory: 21136kb

input:

5
100000 100000
59141 99254
70890 74580
2748 96297
86886 21200
28657 22505
7870 47944
87508 92720
61500 17729
43340 8045
52770 68785
75314 14371
19714 96232
77108 68104
63556 36676
46547 67943
98851 68923
91461 36318
34608 2934
15508 37313
65966 94768
17628 50421
84052 90139
32081 86902
83342 41083
...

output:

99989
99989
99981
99987
99992

result:

ok 5 lines

Test #32:

score: 0
Accepted
time: 127ms
memory: 21164kb

input:

5
100000 100000
30529 96529
74082 59982
50132 4873
43978 73618
19149 90765
19524 71348
83510 49884
42348 61398
97658 95928
13087 18428
68011 22023
95714 5837
26367 34739
35995 33238
26382 32875
93398 11207
58262 76576
44065 13683
67159 79401
16 67061
46360 2783
99386 51142
80896 72801
46169 70280
91...

output:

99986
99989
99979
99987
99988

result:

ok 5 lines

Test #33:

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

input:

5
100000 100000
64216 41115
66033 91766
20629 61497
14734 8394
23049 71529
66858 98621
16033 83721
25691 26243
55258 96454
21319 17959
11495 65222
98028 45830
77838 89823
83195 72946
14668 22461
56184 22224
89421 79424
39036 27994
96404 65243
97107 1247
51769 7447
82335 13726
35718 24717
17651 64206...

output:

99985
99984
99989
99986
99987

result:

ok 5 lines

Test #34:

score: 0
Accepted
time: 128ms
memory: 21240kb

input:

5
100000 100000
70895 45198
52326 64233
5903 52184
68042 32482
59496 8267
91153 19705
6791 65459
37547 57259
44031 90367
28748 11547
87333 74817
8524 28684
10772 63153
80648 20968
47786 74794
32063 89916
97865 46668
17973 80537
6679 184
70291 98165
13534 56375
76933 71944
22509 12628
39227 83824
386...

output:

99981
99987
99989
99989
99989

result:

ok 5 lines

Test #35:

score: 0
Accepted
time: 137ms
memory: 21168kb

input:

5
100000 100000
48582 46059
93020 52152
4141 64554
35921 79884
49171 40319
51528 36946
25346 25008
76710 47961
77660 7508
37189 63940
4850 53337
57427 89065
74766 19263
29266 18163
78986 22299
19286 97281
9623 93653
73898 18692
34136 6186
80683 12485
27108 48234
48427 59868
7527 60315
50575 42778
44...

output:

99978
99983
99983
99984
99992

result:

ok 5 lines

Test #36:

score: 0
Accepted
time: 139ms
memory: 21156kb

input:

5
100000 100000
41765 97260
54587 18014
75416 74258
49108 38134
75009 21010
4816 16805
63481 58669
55610 25835
27968 71334
87173 28879
70842 52933
96677 21499
37197 5816
99092 7678
87716 78765
76078 27529
65967 61690
82837 18067
33985 1174
99405 63349
32433 31932
95745 11567
60345 46799
26589 37985
...

output:

99986
99979
99987
99988
99984

result:

ok 5 lines

Test #37:

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

input:

5
100000 100000
33626 53146
801 7252
46082 33137
87510 18809
30765 72384
13057 26359
70926 88831
45824 58975
68814 70775
30567 37396
73066 92836
48059 33389
84307 78138
87287 62582
26221 89693
31339 30287
3952 8615
11992 36524
30986 2566
4725 67923
15292 2939
74669 87585
99032 73340
9247 59461
79498...

output:

99983
99992
99978
99987
99988

result:

ok 5 lines

Test #38:

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

input:

5
100000 100000
94827 33225
9368 64335
98490 99428
31569 54647
21455 68377
35620 98686
90394 10436
33698 43476
42639 63463
38209 80683
82662 42086
23197 48923
48155 25260
86802 14016
25391 99589
14691 96631
38885 60258
21366 46373
3270 31288
65590 15952
41694 51745
36368 74595
19708 92057
5942 16366...

output:

99981
99983
99985
99988
99987

result:

ok 5 lines

Test #39:

score: 0
Accepted
time: 127ms
memory: 21188kb

input:

5
100000 100000
50713 70927
31310 35001
57369 27430
36436 77699
72830 33514
12470 81939
87853 67946
91030 84321
42080 6856
14022 82907
22565 26172
35086 28737
87773 80751
9002 44008
3614 54849
41641 34616
28914 89413
39823 67566
37366 36608
2867 98811
47292 6477
12386 13282
22057 42011
3226 4030
278...

output:

99986
99982
99987
99988
99989

result:

ok 5 lines

Test #40:

score: 0
Accepted
time: 144ms
memory: 21112kb

input:

5
100000 100000
98088 55302
88393 87409
56365 38785
48081 68390
36118 66476
17501 1407
9457 55819
18635 1250
10576 81795
90013 92503
71815 1310
50621 49482
67599 12970
27732 18987
46214 62394
83793 12653
4749 66083
49672 15658
90280 97472
18192 92509
28802 59663
99396 9766
40774 14514
92835 3978
616...

output:

99985
99986
99987
99985
99988

result:

ok 5 lines