QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#62492#4992. Enigmatic Enumerationpluto1AC ✓2785ms5864kbC++144.2kb2022-11-19 15:45:492022-11-19 15:45:50

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-19 15:45:50]
  • 评测
  • 测评结果:AC
  • 用时:2785ms
  • 内存:5864kb
  • [2022-11-19 15:45:49]
  • 提交

answer

#include <bits/stdc++.h>
/*#include <iostream>
#include <climits>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <bitset>
*/
using namespace  std;
#define  int long long
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define fi first
#define se second
#define pb  push_back
#define inf 1ll<<62
#define db double
#define endl "\n"
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define de_bug(x) cerr << #x << "=" << x << endl
#define all(a) a.begin(),a.end()
#define IOS   std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define  fer(i,a,b)  for(int i=a;i<=b;i++)
#define  der(i,a,b)  for(int i=a;i>=b;i--)
const int mod = 1e9 + 7;
const int N = 3e3 + 10;
const int M = 1e5 + 10;

int h[N], e[M], ne[M], w[M];
int cnt;
array<int, 3> g[M];
int n, m;
int vis[N];
int d[N];
int cnt1;
int num[N];
int pre[N];
int ans = (1 << 30);
void add(int a, int b, int c) {
	e[cnt] = b, ne[cnt] = h[a], w[cnt] = c, h[a] = cnt++;
}

void dij(int s, int t) {
	for (int i = 1; i <= n; i++) {
		vis[i] = 0;
		d[i] = (1 << 30);
	}
	priority_queue<pii, vector<pii>, greater<pii>> q;
	q.push({0, s});
	d[s] = 0;
	while (!q.empty()) {
		pii a = q.top();
		int u = a.second;
		q.pop();
		if (vis[u]) continue;
		vis[u] = 1;
		for (int i = h[u]; ~i; i = ne[i]) {
			int v = e[i];
			if(u == s && v == t || u == t && v == s) continue;
			if (d[v] > d[u] + w[i]) {
				d[v] = d[u] + w[i];
				q.push({d[v], v});
			}
		}
	}
}

void bfs(int a, int b) {
	for(int i = 1; i <= n; i++) {
		d[i] = 1 << 30;
		vis[i] = 0;
	}
	queue<int>q;
	q.push(a);
	q.push(b);
	vis[a] = 1;
	vis[b] = 1;
	d[a] = d[b] = 0;
	while(!q.empty()) {
		int u = q.front();
		q.pop();
		for(int i = h[u]; ~i; i = ne[i]) {
			int v = e[i];
			if(d[v] > d[u] + 1) {
				d[v] = d[u] + 1;
				if(!vis[v]) {
					vis[v] = 1;
					q.push(v);
				}
			} else if(d[v] == ans && d[v] == d[u] + 1 && vis[v]) {
				cnt1++;
			}
		}
	}
}/*
void bfs(int x) {
	//cout<<ans<<endl;
/*	for(int i = 1; i <= n; i++) {
		d[i] = 1 << 30;
	//	vis[i] = 0;
		num[i] = 0;
		pre[i] = 0;
	}
	queue<int>q;
	q.push(x);
	d[x] = 0;
	//vis[x] = 1;
	num[x] = 1;
	while(!q.empty()) {
		int t = q.front();
		q.pop();
		if(d[t] * 2 == ans) {
			cnt1 += 1ll * num[x] * (num[x] - 1) / 2;
		}
		for(int i = h[t]; ~i; i = ne[i]) {
			int v = e[i];
			if(d[v] == 1 << 30) {
				d[v] = d[t] + 1;
				pre[v] = t;
				num[v] = num[t];
			//	if(!vis[v]) {
					q.push(v);
			//		vis[v] = 1;
			//	}
			} /*else if(d[v] == ans && vis[v]  && d[v] == d[t] + 1) {
				cnt1++;
			}*/
//	else if(d[v] == d[t] + 1) {
//		num[v] += num[x];
//	}
//}
//}
//}
void bfs(int t) {
	for(int i = 1; i <= n; i++) {
		d[i] = 1 << 30;
		num[i] = 0;
		pre[i] = 0;
	}
	d[t] = 0, num[t] = 1;
	queue<int> q;
	q.push(t);
	while(!q.empty()) {
		int x = q.front();
		q.pop();
		if(d[x] * 2 == ans) {
			cnt1 += num[x] * (num[x] - 1) / 2;
		}
		for(int i = h[x]; ~i; i = ne[i]) {
			int y = e[i];
			if(d[y] == 1 << 30) {
				d[y] = d[x] + 1;
				pre[y] = x;
				num[y] = num[x];
				q.push(y);
			} else if(d[y] == d[x] + 1) {
				num[y] += num[x];
			}
		}
	}
}
void  solve() {
	cin >> n >> m;
	memset(h, -1, sizeof(h));
	for (int i = 1; i <= m; i++) {
		int a, b;
		cin >> a >> b ;
		add(a, b, 1);
		add(b, a, 1);
		g[i] = {a, b, 1};
	}

	for (int i = 1; i <= m; i++) {
		int a = g[i][0];
		int b = g[i][1];
		int c = g[i][2];
		dij(a, b);
		ans = min(ans, d[b] + c);
	}
	//cout << ans << endl;
	int tmp = ans;
	if(ans % 2 == 0) {
		//ans /= 2;
	} else ans = (ans - 1) / 2;
	if(tmp % 2 == 1) {
		for (int i = 1; i <= m; i++) {
			int a = g[i][0];
			int b = g[i][1];
			bfs(a, b);
		}

	} else {
		for(int i = 1; i <= n; i++) {
			bfs(i);
		}
		//cout << cnt1 << endl;
	}
	//cout<<cnt1<<endl;
	/*for(int i = 1; i <= n; i++) {
		cout << d[i] << endl;
	}*/
	cout << cnt1 / tmp << endl;

}

signed main() {
	IOS;
	int _ = 1;
	//cin>>_;
	while( _-- )
		solve();
	return 0;
}

/*
9 12
1 2
2 3
4 5
5 6
7 8
8 9
1 4
2 5
3 6
4 7
5 8
6 9

*/



詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3416kb

input:

4 4
1 2
2 3
3 4
4 1

output:

1

result:

ok single line: '1'

Test #2:

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

input:

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

output:

10

result:

ok single line: '10'

Test #3:

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

input:

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

output:

2

result:

ok single line: '2'

Test #4:

score: 0
Accepted
time: 686ms
memory: 3768kb

input:

110 5995
109 20
100 23
99 65
106 40
105 62
89 67
57 9
83 38
38 20
28 11
39 28
32 20
108 90
96 50
97 51
80 40
64 48
101 27
84 27
43 35
103 79
70 32
29 28
109 2
43 16
110 94
101 71
84 67
23 19
33 17
107 79
90 33
83 64
57 39
105 46
47 1
80 79
93 67
78 53
34 20
105 15
77 66
65 63
102 57
76 59
47 40
95 4...

output:

215820

result:

ok single line: '215820'

Test #5:

score: 0
Accepted
time: 695ms
memory: 3772kb

input:

110 5985
50 38
109 70
110 85
50 23
71 51
52 2
43 32
74 28
98 13
103 94
108 54
41 12
55 12
51 10
44 2
56 35
8 6
27 2
72 19
92 65
64 42
31 20
110 67
74 46
93 57
59 5
63 50
33 31
98 42
75 59
103 87
81 79
99 20
100 84
89 87
87 78
67 56
85 74
14 7
103 16
42 41
29 13
68 26
110 7
91 63
86 78
86 85
44 42
10...

output:

214742

result:

ok single line: '214742'

Test #6:

score: 0
Accepted
time: 406ms
memory: 3896kb

input:

154 5929
68 88
68 153
67 84
64 134
51 120
38 102
68 82
54 105
50 135
2 103
75 140
17 150
40 127
19 152
8 98
70 144
76 134
7 94
12 109
33 152
14 124
7 96
30 140
9 118
71 110
12 121
17 123
3 112
63 96
35 153
43 122
36 82
24 114
21 111
69 88
76 117
41 126
68 151
32 104
39 150
19 133
1 140
14 114
33 145...

output:

8561476

result:

ok single line: '8561476'

Test #7:

score: 0
Accepted
time: 406ms
memory: 3896kb

input:

154 5919
47 107
73 107
15 125
22 151
65 91
54 151
52 100
64 127
77 115
65 80
3 99
50 86
12 139
57 88
48 137
71 148
44 95
31 122
49 139
3 149
43 107
34 85
67 142
75 97
56 146
72 135
72 116
18 94
2 97
63 151
54 145
32 101
62 128
75 89
36 147
41 120
35 142
46 129
65 94
6 141
53 146
21 132
29 98
55 81
2...

output:

8503911

result:

ok single line: '8503911'

Test #8:

score: 0
Accepted
time: 411ms
memory: 3908kb

input:

154 5919
40 117
56 137
52 141
57 118
29 107
18 128
74 111
54 78
73 87
69 134
38 124
50 112
70 99
43 122
72 87
52 134
57 123
43 86
4 79
52 129
68 126
58 127
77 128
25 141
61 127
57 146
7 124
39 83
55 111
62 130
2 83
44 104
2 119
40 105
8 152
36 130
67 100
3 106
9 99
6 118
43 141
40 126
76 109
51 87
1...

output:

8503986

result:

ok single line: '8503986'

Test #9:

score: 0
Accepted
time: 155ms
memory: 3768kb

input:

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

output:

1

result:

ok single line: '1'

Test #10:

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

input:

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

output:

2

result:

ok single line: '2'

Test #11:

score: 0
Accepted
time: 141ms
memory: 3724kb

input:

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

output:

1

result:

ok single line: '1'

Test #12:

score: 0
Accepted
time: 79ms
memory: 3724kb

input:

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

output:

2

result:

ok single line: '2'

Test #13:

score: 0
Accepted
time: 74ms
memory: 3620kb

input:

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

output:

1

result:

ok single line: '1'

Test #14:

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

input:

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

output:

1

result:

ok single line: '1'

Test #15:

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

input:

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

output:

1

result:

ok single line: '1'

Test #16:

score: 0
Accepted
time: 157ms
memory: 3628kb

input:

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

output:

2

result:

ok single line: '2'

Test #17:

score: 0
Accepted
time: 149ms
memory: 5864kb

input:

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

output:

2

result:

ok single line: '2'

Test #18:

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

input:

3000 3
1 2
2 3
3 1

output:

1

result:

ok single line: '1'

Test #19:

score: 0
Accepted
time: 711ms
memory: 3900kb

input:

113 6000
107 75
95 35
65 37
103 96
47 44
87 85
93 13
63 46
66 65
99 93
107 37
78 54
99 94
99 80
106 6
50 33
49 35
66 20
80 64
61 52
48 9
81 41
42 4
108 22
104 25
108 52
112 11
87 61
16 8
75 50
14 2
104 68
81 7
57 33
58 31
73 65
78 42
107 104
106 96
76 27
66 6
76 56
95 13
105 6
92 36
81 73
95 8
26 3
...

output:

199594

result:

ok single line: '199594'

Test #20:

score: 0
Accepted
time: 980ms
memory: 3900kb

input:

241 6000
92 87
180 129
111 76
230 169
143 20
105 74
194 88
62 12
118 85
115 95
236 117
53 49
175 16
228 7
128 27
174 173
177 85
54 24
191 44
212 141
208 164
7 2
63 16
91 25
179 45
190 162
186 41
131 44
209 58
77 71
65 6
164 6
128 52
145 5
97 44
195 155
144 37
185 126
232 66
120 104
160 70
127 118
20...

output:

20438

result:

ok single line: '20438'

Test #21:

score: 0
Accepted
time: 1092ms
memory: 3932kb

input:

629 6000
587 450
474 389
622 552
155 92
426 403
329 73
473 381
136 131
225 108
535 199
568 488
436 220
404 269
606 190
465 344
37 25
342 239
541 364
404 150
409 176
471 433
455 74
408 152
371 259
430 104
548 273
397 308
447 317
343 41
105 66
287 78
509 28
171 164
363 238
506 168
550 102
547 513
606 ...

output:

1160

result:

ok single line: '1160'

Test #22:

score: 0
Accepted
time: 1314ms
memory: 5792kb

input:

1100 6000
916 280
258 17
974 279
964 233
567 262
856 688
422 314
945 355
1057 935
651 410
894 605
714 145
674 506
451 56
786 603
530 14
306 150
1084 15
791 682
827 747
933 208
712 31
491 263
449 374
784 683
655 396
683 89
743 581
785 688
1044 322
927 44
711 542
889 288
373 295
654 392
1003 140
754 6...

output:

211

result:

ok single line: '211'

Test #23:

score: 0
Accepted
time: 2331ms
memory: 3856kb

input:

2420 6000
936 243
1657 936
2030 1517
1601 266
1730 189
1850 843
1734 1127
501 476
962 952
1894 115
2066 862
1499 1266
2404 1837
2221 1403
1719 846
985 429
1576 43
2292 406
1603 1527
2172 1283
2042 1306
1509 1472
1931 1198
1875 586
1905 661
2236 1112
971 338
1997 1296
1393 1225
135 26
2129 432
1545 9...

output:

14

result:

ok single line: '14'

Test #24:

score: 0
Accepted
time: 2691ms
memory: 4052kb

input:

3000 6000
1000 830
2457 395
2683 287
982 722
2746 1289
2223 172
1931 979
2429 1200
2536 581
2673 1998
1926 1453
909 31
1342 1040
2579 1502
2569 534
2684 1771
1730 456
2119 1774
2393 130
1389 1172
2458 1427
2937 452
1612 1497
2601 1561
2689 2280
1912 1271
2214 1245
1676 1486
2696 2066
2319 105
2029 1...

output:

13

result:

ok single line: '13'

Test #25:

score: 0
Accepted
time: 2008ms
memory: 3912kb

input:

3000 5000
2786 2564
2999 2133
625 377
2806 208
429 222
2846 938
1314 1076
1102 601
716 231
786 289
1521 268
1358 117
2878 1045
1247 803
1488 19
1959 569
2912 1590
2137 1535
1673 1671
2407 388
1941 27
1776 374
1612 280
2193 1776
1757 794
2608 1785
1911 570
2215 1914
1335 921
1157 69
2183 319
1951 351...

output:

11

result:

ok single line: '11'

Test #26:

score: 0
Accepted
time: 715ms
memory: 5812kb

input:

3000 3000
2190 243
2598 2062
1346 527
2880 2843
2735 1419
919 395
2951 1434
1282 1230
1799 358
1904 1533
2969 709
2146 366
2515 829
2494 814
1704 990
2295 2218
985 35
545 45
2589 271
841 42
2918 2845
503 488
2073 1928
1744 772
2571 2457
1740 826
2287 1149
2511 1969
2830 744
840 104
2476 1087
823 626...

output:

2

result:

ok single line: '2'

Test #27:

score: 0
Accepted
time: 36ms
memory: 3452kb

input:

300 1000
260 208
83 78
299 222
30 127
166 247
72 2
104 259
123 249
177 113
168 83
224 34
261 135
256 251
271 283
88 100
217 204
137 274
87 213
35 174
80 42
140 232
205 226
193 118
41 87
149 242
299 159
124 137
116 61
108 215
129 200
295 80
45 152
95 183
18 82
300 234
82 253
51 297
237 186
116 135
11...

output:

5050

result:

ok single line: '5050'

Test #28:

score: 0
Accepted
time: 732ms
memory: 3892kb

input:

3000 3000
112 236
1613 876
1255 1067
1718 898
716 848
438 886
618 1228
249 562
272 1404
709 750
2368 742
2043 555
1990 1772
1398 1507
64 573
1619 1000
2005 127
727 332
1239 2241
493 1746
168 2184
87 1396
802 56
2737 1828
373 413
2899 492
2051 1211
2928 2059
2195 2581
1551 339
715 360
137 2244
1105 2...

output:

4

result:

ok single line: '4'

Test #29:

score: 0
Accepted
time: 748ms
memory: 3864kb

input:

3000 3000
2636 1293
2820 2928
937 2114
817 1970
1833 2709
2725 784
1222 2736
685 2416
2263 56
2461 2687
46 687
1746 727
2995 1693
1744 1725
1549 999
269 1942
1621 987
960 1321
1150 121
1011 2411
216 711
2561 1373
2357 313
1178 480
1223 1070
411 1068
2340 169
2870 2954
1438 1872
2945 2462
569 126
117...

output:

4

result:

ok single line: '4'

Test #30:

score: 0
Accepted
time: 661ms
memory: 3776kb

input:

3000 3000
2134 1172
1170 1252
287 2729
1192 263
1111 755
2068 2065
1958 157
2480 2330
2720 1265
2284 2992
625 2976
456 384
1421 1452
578 2964
758 1746
606 1186
751 1283
2270 1903
481 1996
315 1790
144 608
2544 1993
2181 1193
2015 1990
298 2026
402 695
949 1841
1541 1526
1182 2115
2559 77
1047 1791
2...

output:

1

result:

ok single line: '1'

Test #31:

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

input:

3000 3000
844 2597
815 1469
1909 1441
1737 2359
2633 1335
1688 739
774 2571
1446 2707
196 2526
363 1318
1245 807
1123 456
1684 1924
195 1198
1674 2382
2699 2618
1779 1168
2083 623
2888 995
2060 1385
2737 540
20 2336
146 1829
1961 1804
1171 920
2654 467
933 1558
259 2061
153 2828
2802 929
2144 612
16...

output:

1

result:

ok single line: '1'

Test #32:

score: 0
Accepted
time: 626ms
memory: 5708kb

input:

3000 3000
1941 2002
188 1682
2584 1712
735 1859
2331 2591
655 1203
1979 1570
1965 1959
670 1992
1936 1728
2612 1919
1663 54
2901 1412
1137 1955
2601 2903
354 1732
799 2396
426 2346
1595 91
810 1415
2358 105
1455 430
1231 1457
1302 787
1100 2037
234 36
2977 982
2789 1436
2632 2775
1057 491
630 446
14...

output:

1

result:

ok single line: '1'

Test #33:

score: 0
Accepted
time: 613ms
memory: 3840kb

input:

3000 3000
2988 1136
1011 498
1393 469
532 1112
1577 1634
138 2979
2238 60
2940 1257
2091 867
572 185
924 2263
497 953
727 1480
2097 2390
352 1422
2703 1925
1743 2316
382 893
2508 774
1935 846
2942 1179
2287 700
2778 648
1885 2991
2083 21
2075 103
1131 1193
2929 1693
2449 2187
1531 2943
2487 590
490 ...

output:

1

result:

ok single line: '1'

Test #34:

score: 0
Accepted
time: 788ms
memory: 5700kb

input:

3000 3000
2340 459
1367 1528
1481 1698
1664 1088
550 684
2557 528
1779 1806
603 2728
148 693
1995 1896
1447 2030
717 1774
1984 1037
1742 622
981 1323
2450 2332
1179 1639
1927 1117
2420 1635
930 1523
712 962
346 265
589 57
1461 2012
668 2126
757 107
1091 1751
1536 1769
2039 1864
1820 1672
2833 681
13...

output:

125

result:

ok single line: '125'

Test #35:

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

input:

3000 3000
279 1338
290 1268
1249 755
36 2639
2227 1641
2566 885
31 1030
919 981
2946 752
2573 1057
1981 1603
2636 697
1402 1983
656 2614
1481 1120
152 2375
1086 1928
2333 144
2953 2022
65 745
1757 120
2409 1702
1619 2584
2092 2807
1616 2091
2059 1298
2738 1495
1039 2878
2829 127
916 2094
2671 1995
7...

output:

133

result:

ok single line: '133'

Test #36:

score: 0
Accepted
time: 2428ms
memory: 4020kb

input:

3000 6000
2240 1343
763 71
334 1901
1456 1397
1875 26
2610 32
2414 26
690 2376
2709 2720
230 2102
1937 1048
1795 632
698 1754
1153 1027
2917 1490
1733 876
444 2243
1212 1090
2895 1081
1709 1094
2279 556
2633 980
1549 509
408 605
2585 2642
1554 2631
2967 753
258 499
49 501
945 1189
1429 2461
2824 267...

output:

20

result:

ok single line: '20'

Test #37:

score: 0
Accepted
time: 2708ms
memory: 4092kb

input:

3000 6000
356 2812
493 2149
1050 2454
2081 2831
619 2459
1493 512
2062 2327
1093 688
940 953
665 852
2149 1961
2240 1007
1265 1045
188 1887
622 2073
2025 2348
231 1573
2504 1953
2935 1119
1192 2765
1588 1653
199 1098
1987 2011
1783 1055
1046 2707
2257 1882
2059 1388
1721 2124
1395 1494
2620 2509
191...

output:

111

result:

ok single line: '111'

Test #38:

score: 0
Accepted
time: 2785ms
memory: 4100kb

input:

3000 6000
1085 2640
749 1483
221 486
520 1281
1056 100
897 2976
2923 339
980 1688
2453 257
357 856
2546 1434
516 747
1938 1893
2467 1547
2765 210
2412 1559
631 1444
2362 2090
1973 2818
695 140
398 107
480 1867
332 1930
724 2809
1743 1942
2973 425
1557 1299
1384 1485
1321 1607
2491 2898
1306 1652
228...

output:

4639

result:

ok single line: '4639'

Test #39:

score: 0
Accepted
time: 2531ms
memory: 4136kb

input:

3000 6000
1857 461
1219 723
429 2577
2693 2979
2211 2439
2332 570
969 2038
1668 2372
1053 305
2335 354
677 2278
371 1826
92 2826
2747 2289
1889 469
553 33
1728 2914
1823 753
2108 1996
1844 815
1284 1949
1453 1274
1511 204
828 707
441 2961
1677 2002
2707 1393
1564 374
520 2144
545 1860
457 1754
505 1...

output:

10388

result:

ok single line: '10388'

Test #40:

score: 0
Accepted
time: 1458ms
memory: 3720kb

input:

3000 4500
1 2
1 3000
1 2090
2 3
2 1424
3 4
3 597
4 5
4 1521
5 6
5 1926
6 7
6 495
7 8
7 116
8 9
8 2118
9 10
9 251
10 11
10 911
11 12
11 1085
12 13
12 518
13 14
13 1227
14 15
14 195
15 16
15 714
16 17
16 308
17 18
17 339
18 19
18 2167
19 20
19 504
20 21
20 862
21 22
21 79
22 23
22 1371
23 24
23 2545
2...

output:

102

result:

ok single line: '102'

Test #41:

score: 0
Accepted
time: 2114ms
memory: 3988kb

input:

3000 6000
1 2
1 3000
1 1705
1 2018
2 3
2 1613
2 2829
3 4
3 2314
3 221
4 5
4 1993
4 2650
5 6
5 1063
5 2768
6 7
6 482
6 2459
7 8
7 1107
7 1843
8 9
8 2453
8 1332
9 10
9 1646
9 1507
10 11
10 459
10 810
11 12
11 2204
11 1764
12 13
12 1901
12 58
13 14
13 883
13 2928
14 15
14 1042
14 1019
15 16
15 2626
15 ...

output:

136

result:

ok single line: '136'

Test #42:

score: 0
Accepted
time: 602ms
memory: 3780kb

input:

2000 3000
1 2
1 2000
1 1873
2 3
2 465
3 4
3 858
4 5
4 1986
5 6
5 1038
6 7
6 1928
7 8
7 297
8 9
8 1730
9 10
9 910
10 11
10 105
11 12
11 1562
12 13
12 1385
13 14
13 712
14 15
14 571
15 16
15 1080
16 17
16 1725
17 18
17 292
18 19
18 143
19 20
19 857
20 21
20 115
21 22
21 1779
22 23
22 914
23 24
23 1308...

output:

45

result:

ok single line: '45'

Test #43:

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

input:

1000 2000
1 2
1 1000
1 281
1 398
2 3
2 470
2 90
3 4
3 344
3 264
4 5
4 465
4 416
5 6
5 988
5 20
6 7
6 861
6 239
7 8
7 673
7 901
8 9
8 227
8 360
9 10
9 968
9 125
10 11
10 751
10 345
11 12
11 807
11 311
12 13
12 117
12 35
13 14
13 746
13 909
14 15
14 755
14 77
15 16
15 647
15 843
16 17
16 196
16 932
17...

output:

51

result:

ok single line: '51'

Test #44:

score: 0
Accepted
time: 347ms
memory: 3748kb

input:

1000 3000
1 2
1 1000
1 694
1 979
1 12
1 313
2 3
2 939
2 806
2 25
2 892
3 4
3 41
3 453
3 428
3 152
4 5
4 571
4 590
4 418
4 446
5 6
5 454
5 635
5 45
5 396
6 7
6 197
6 529
6 30
6 32
7 8
7 678
7 372
7 814
7 25
8 9
8 605
8 828
8 366
8 328
9 10
9 635
9 170
9 514
9 43
10 11
10 538
10 664
10 920
10 172
11 1...

output:

76

result:

ok single line: '76'