QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#21128#1824. Special CycleezoilearnerAC ✓889ms5332kbC++144.1kb2022-03-01 08:46:212022-05-08 02:11:55

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-08 02:11:55]
  • 评测
  • 测评结果:AC
  • 用时:889ms
  • 内存:5332kb
  • [2022-03-01 08:46:21]
  • 提交

answer

#include <iostream>
#include <vector>
using namespace std ;
const int MAXN = 1000 ;
vector<vector<pair<int,int>>> edges, oedges ;
int adj[MAXN][MAXN], oadj[MAXN][MAXN] ;
     // 0 means this edge is deleted or never existed
char aspec[MAXN][MAXN] ;
vector<char> visited, ndel, ondel ;
vector<int> tin, low, live, olive, isspec ;
int n, m, k ;
int timer ;
void rmedge(int a, int b) {
   if (adj[a][b] == 0)
      return ;
   adj[a][b] = adj[b][a] = 0 ;
}
void rmnode(int a) {
   if (ndel[a])
      return ;
   ndel[a] = 1 ;
   for (auto b: edges[a]) {
      rmedge(a, b.first) ;
      if (b.second)
         rmnode(b.first) ;
   }
}
void dfs(int v, int p = -1) {
   visited[v] = true ;
   if (ndel[v])
      return;
   tin[v] = low[v] = timer++ ;
   for (auto b: edges[v]) {
      int to = b.first ;
      if (ndel[to] || adj[v][to] == 0 || to == p) continue ;
      if (visited[to]) {
         low[v] = min(low[v], tin[to]) ;
      } else {
         dfs(to, v) ;
         low[v] = min(low[v], low[to]) ;
         if (low[to] > tin[v])
            adj[v][to] = adj[to][v] = -1 ;
      }
   }
}
void find_bridges() {
   timer = 0 ;
   visited.assign(n, false) ;
   tin.assign(n, -1) ;
   low.assign(n, -1) ;
   for (int i=0; i<n; i++)
      if (!visited[i])
         dfs(i) ;
}
void restore() {
   edges = oedges ;
   ndel = ondel ;
   live = olive ;
   for (int i=0; i<n; i++)
      for (int j=0; j<n; j++)
         adj[i][j] = oadj[i][j] ;
}
void save() {
   oedges = edges ;
   ondel = ndel ;
   olive = live ;
   for (int i=0; i<n; i++)
      for (int j=0; j<n; j++)
         oadj[i][j] = adj[i][j] ;
}
void rmedge2(int a, int b) {
   rmedge(a, b) ;
   if (aspec[a][b]) {
      rmnode(a) ;
      rmnode(b) ;
   }
}
int clean() {
   while (1) {
      int changed = 0 ;
      find_bridges() ;
      for (int a=0; a<n; a++)
         for (auto b: edges[a])
            if (adj[a][b.first] < 0) {
               rmedge2(a, b.first) ;
               changed = 1 ;
            }
      if (!changed)
         break ;
   }
   for (int a=0; a<n; a++) {
      vector<pair<int, int>> ne ;
      for (auto b: edges[a])
         if (adj[a][b.first])
            ne.push_back(b) ;
      swap(edges[a], ne) ;
   }
   live.clear() ;
   for (int a=0; a<n; a++)
      if (!ndel[a] && edges[a].size() > 1)
         live.push_back(a) ;
   return live.size() ;
}
int main() {
   cin >> n >> m >> k ;
   isspec.resize(n) ;
   edges.resize(n) ;
   visited.resize(n) ;
   tin.resize(n) ;
   low.resize(n) ;
   for (int i=0; i<m; i++) {
      int a, b ;
      cin >> a >> b ;
      int s = (i < k) ;
      a-- ;
      b-- ;
      edges[a].push_back({b,s}) ;
      edges[b].push_back({a,s}) ;
      adj[a][b] = adj[b][a] = 1 ;
      if (s) {
         isspec[a]++ ;
         isspec[b]++ ;
         aspec[a][b] = aspec[b][a] = 1 ;
      }
   }
   ndel.resize(n) ;
   for (int a=0; a<n; a++)
      if (isspec[a] > 2)
         rmnode(a) ;
   for (int a=0; a<n; a++)
      if (isspec[a] == 2)
         for (auto b: edges[a])
            if (b.second == 0)
               rmedge(a, b.first) ;
   if (clean() == 0) {
      cout << -1 << endl ;
      exit(0) ;
   }
   while (1) {
      int changed = 0 ;
      for (int i=0; i<n; i++)
         for (int j=i+1; j<n; j++)
            if (adj[i][j] == 1) {
               save() ;
               rmedge2(i, j) ;
               if (clean() == 0) {
                  restore() ;
               } else {
                  changed++ ;
               }
            }
      if (changed == 0)
         break ;
   }
   cout << live.size() << endl ;
   int a = live[0] ;
   int b = edges[a][0].first ;
   visited[a] = 2 ;
   visited[b] = 2 ;
   vector<int> sol ;
   sol.push_back(a) ;
   sol.push_back(b) ;
   while (1) {
      int c = -1 ;
      for (int i=0; i<(int)edges[b].size(); i++)
         if (visited[edges[b][i].first] != 2)
            c = edges[b][i].first ;
      if (c < 0)
         break ;
      sol.push_back(c) ;
      visited[c] = 2 ;
      a = b ;
      b = c ;
   }
   for (auto a: sol)
      cout << " " << 1+a ;
   cout << endl ;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3792kb

input:

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

output:

6
 3 4 5 6 7 8

result:

ok OK

Test #2:

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

input:

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

output:

-1

result:

ok OK: both impossible

Test #3:

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

input:

66 88 22
3 4
6 11
9 10
12 17
15 16
18 23
21 22
24 29
27 28
30 35
33 34
36 41
39 40
42 47
45 46
48 53
51 52
54 59
57 58
60 65
63 64
5 66
1 2
2 3
1 3
4 5
5 6
4 6
7 8
8 9
7 9
10 11
11 12
10 12
13 14
14 15
13 15
16 17
17 18
16 18
19 20
20 21
19 21
22 23
23 24
22 24
25 26
26 27
25 27
28 29
29 30
28 30
31...

output:

22
 5 66 65 60 59 54 53 48 47 42 41 36 35 30 29 24 23 18 17 12 11 6

result:

ok OK

Test #4:

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

input:

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

output:

9
 11 26 32 15 13 45 42 16 52

result:

ok OK

Test #5:

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

input:

98 93 36
15 81
19 93
57 65
46 80
34 47
9 25
58 78
13 61
8 18
73 90
2 39
5 82
49 64
4 62
40 85
14 79
47 73
10 83
43 65
30 59
80 81
40 41
95 98
3 92
15 55
4 98
31 37
74 86
46 69
24 27
70 79
21 28
12 83
60 84
52 98
17 96
83 93
6 32
53 96
29 66
50 66
27 71
40 53
81 94
14 18
63 98
10 59
10 22
8 25
19 85
...

output:

7
 5 82 24 27 42 18 8

result:

ok OK

Test #6:

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

input:

146 277 99
43 110
11 123
76 90
60 88
107 129
38 129
23 49
9 56
125 144
89 138
31 88
74 136
46 126
107 122
31 53
8 18
25 42
12 123
3 128
68 121
28 88
35 65
24 52
24 53
74 108
28 79
85 94
64 113
6 77
128 136
111 146
41 136
14 111
88 125
41 83
48 145
13 29
13 33
69 96
46 130
11 92
31 58
65 112
96 104
1...

output:

18
 1 80 54 34 44 101 37 116 102 92 11 123 12 120 48 145 105 133

result:

ok OK

Test #7:

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

input:

29 41 10
12 20
10 19
1 5
4 21
13 24
6 9
1 12
11 27
12 22
5 14
5 8
6 27
7 21
20 25
1 8
1 2
8 9
2 26
7 15
18 27
6 19
8 24
7 11
20 26
6 15
2 8
16 19
20 29
14 21
1 7
16 21
10 13
11 29
16 17
8 21
18 20
1 3
2 17
2 9
5 24
22 28

output:

7
 6 9 8 24 13 10 19

result:

ok OK

Test #8:

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

input:

60 97 23
45 52
18 55
1 53
5 35
37 47
25 43
11 55
5 41
36 59
26 40
38 39
21 51
30 32
27 60
46 51
21 50
19 35
20 26
24 31
4 25
8 37
5 33
33 49
33 46
53 59
18 22
21 37
19 41
11 59
25 52
23 54
22 36
31 55
38 45
28 56
41 45
7 27
24 30
21 57
11 56
15 56
6 22
42 56
15 39
48 53
5 29
31 41
2 31
17 27
5 36
7 ...

output:

6
 11 55 18 22 36 59

result:

ok OK

Test #9:

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

input:

62 41 13
12 48
6 26
37 57
2 23
11 62
42 45
24 59
50 51
16 55
41 60
23 54
12 45
6 51
5 21
20 51
25 42
13 26
37 62
19 61
5 40
7 42
6 37
22 28
46 49
10 23
16 31
44 62
24 57
21 29
15 18
33 61
29 57
21 41
23 27
40 42
5 49
32 55
11 37
44 46
40 59
34 62

output:

11
 5 40 59 24 57 37 11 62 44 46 49

result:

ok OK

Test #10:

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

input:

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

output:

3
 3 6 5

result:

ok OK

Test #11:

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

input:

8 17 6
4 7
1 5
3 6
5 7
3 5
3 4
2 4
1 6
2 6
2 7
6 7
4 6
3 8
1 2
7 8
1 3
2 8

output:

-1

result:

ok OK: both impossible

Test #12:

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

input:

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

output:

-1

result:

ok OK: both impossible

Test #13:

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

input:

23 14 3
1 20
5 10
21 22
4 23
8 14
11 23
12 14
17 20
10 14
2 13
1 23
1 15
1 9
5 15

output:

-1

result:

ok OK: both impossible

Test #14:

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

input:

3 2 1
2 3
1 3

output:

-1

result:

ok OK: both impossible

Test #15:

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

input:

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

output:

-1

result:

ok OK: both impossible

Test #16:

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

input:

28 91 42
10 23
4 23
9 22
3 9
14 17
12 13
4 20
14 24
8 28
23 24
4 6
4 19
3 8
3 4
15 25
4 15
7 23
3 24
4 13
4 28
4 16
9 11
10 13
15 27
11 16
23 27
5 24
16 17
19 25
13 19
7 27
1 12
26 27
4 7
16 22
9 15
13 23
4 8
9 13
2 26
21 24
4 26
18 24
10 27
24 26
19 26
8 18
1 6
2 14
5 12
4 5
5 17
19 20
15 17
14 23
...

output:

-1

result:

ok OK: both impossible

Test #17:

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

input:

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

output:

8
 2 3 4 8 9 10 6 7

result:

ok OK

Test #18:

score: 0
Accepted
time: 858ms
memory: 5300kb

input:

150 10783 2
22 139
31 85
18 37
10 73
62 129
14 22
33 68
31 140
88 136
39 58
20 40
26 32
64 77
20 79
72 126
53 146
42 68
16 145
6 76
42 66
68 106
64 134
8 123
110 119
89 124
10 26
100 144
60 80
69 74
52 100
93 118
7 73
11 98
44 148
33 129
140 145
53 115
23 52
23 141
6 48
6 150
3 58
43 97
35 132
38 89...

output:

3
 148 150 149

result:

ok OK

Test #19:

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

input:

92 4162 52
2 17
55 84
28 64
16 24
32 71
11 18
56 69
78 88
24 30
15 80
12 28
24 26
5 72
61 81
21 52
30 36
35 55
7 72
35 57
65 73
14 21
6 54
6 9
30 90
51 69
29 76
38 63
51 65
20 82
49 79
61 88
79 82
35 66
51 88
21 36
42 51
33 49
1 9
58 67
43 53
22 83
3 9
5 19
23 42
48 74
39 61
16 70
10 33
49 73
57 84
...

output:

3
 89 91 92

result:

ok OK

Test #20:

score: 0
Accepted
time: 460ms
memory: 5112kb

input:

138 8440 10
48 76
49 78
21 97
106 123
55 80
54 127
27 42
50 107
13 27
9 28
61 114
98 131
3 107
57 109
113 135
65 119
13 56
14 32
40 47
75 100
72 123
31 63
46 130
118 119
57 74
52 95
110 132
51 135
43 82
28 48
34 63
11 97
15 47
60 78
25 30
75 111
31 87
61 73
17 51
2 22
25 117
10 95
5 50
66 138
18 100...

output:

3
 135 138 137

result:

ok OK

Test #21:

score: 0
Accepted
time: 70ms
memory: 4708kb

input:

107 3805 22
87 106
25 94
71 73
20 54
50 85
25 80
7 14
25 37
11 65
50 88
89 98
30 68
39 63
34 100
58 92
1 37
29 103
34 90
3 32
65 80
14 69
17 101
11 13
76 104
16 39
31 41
39 70
71 86
15 25
82 95
19 58
46 55
56 57
54 78
22 50
6 42
2 58
19 78
9 46
38 88
45 93
74 86
19 101
12 74
36 60
60 97
62 82
46 59
...

output:

3
 99 102 104

result:

ok OK

Test #22:

score: 0
Accepted
time: 43ms
memory: 4648kb

input:

98 4558 31
6 89
28 86
29 97
6 30
5 96
8 87
15 51
38 73
31 35
15 50
15 49
39 70
25 40
20 91
20 56
37 42
22 52
5 20
2 59
2 56
13 50
12 61
45 49
1 87
22 65
27 96
7 24
5 48
1 6
16 95
48 73
53 73
20 62
10 82
79 92
49 58
17 24
79 82
60 80
89 95
9 31
34 95
1 5
36 41
2 39
55 74
17 94
18 46
17 27
29 40
67 82...

output:

3
 93 94 98

result:

ok OK

Test #23:

score: 0
Accepted
time: 551ms
memory: 5172kb

input:

141 8460 2
35 140
59 115
100 128
22 128
49 120
36 37
60 124
84 102
3 83
26 131
38 129
27 61
1 62
28 73
9 66
8 60
102 106
4 101
44 104
51 77
8 98
23 96
74 92
22 137
113 134
25 138
67 133
35 122
2 121
8 109
36 42
110 118
78 114
88 110
73 76
102 125
26 36
54 141
127 134
50 53
73 77
74 103
66 139
61 89
...

output:

4
 137 141 138 139

result:

ok OK

Test #24:

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

input:

149 7462 69
4 38
29 40
112 137
20 115
38 135
65 81
55 137
4 70
29 87
9 16
44 95
25 120
15 34
121 136
69 104
14 35
2 76
51 78
9 145
3 55
106 136
91 115
11 102
9 119
86 126
38 119
7 119
96 110
30 135
113 132
49 65
8 118
2 25
47 83
9 91
93 101
107 139
96 137
62 119
3 44
39 146
104 110
37 89
101 133
68 ...

output:

3
 147 148 149

result:

ok OK

Test #25:

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

input:

148 10057 54
17 48
83 85
2 47
139 147
74 77
77 79
35 78
64 77
39 62
23 96
23 40
85 103
18 142
17 63
52 127
7 93
80 101
73 117
30 138
37 122
97 106
43 119
18 48
70 105
34 106
40 57
72 92
48 136
95 100
33 34
37 106
68 80
116 122
21 105
45 69
45 141
43 72
18 47
73 141
44 86
50 65
1 141
31 94
6 8
2 145
...

output:

3
 143 146 148

result:

ok OK

Test #26:

score: 0
Accepted
time: 499ms
memory: 4972kb

input:

136 8924 10
40 127
57 132
1 106
81 132
80 107
106 132
35 74
111 122
18 102
88 123
5 10
23 96
65 90
10 112
81 82
32 74
41 89
105 116
4 11
89 127
99 100
35 49
51 79
56 108
51 60
81 134
10 101
103 130
22 105
65 113
4 33
61 69
7 27
21 112
46 74
9 100
110 111
100 120
42 75
33 66
98 104
45 121
2 17
33 82
...

output:

3
 134 136 135

result:

ok OK

Test #27:

score: 0
Accepted
time: 234ms
memory: 5072kb

input:

134 7947 27
24 32
14 132
3 85
18 76
10 82
3 98
34 125
37 88
8 132
23 118
1 57
7 31
6 32
21 58
65 104
117 131
114 118
52 117
70 83
46 55
47 85
15 24
47 60
28 62
51 88
90 98
1 98
40 68
9 69
37 111
28 132
61 72
54 110
21 22
13 39
6 124
55 105
61 125
14 102
96 127
36 58
73 125
64 110
20 130
70 123
61 62...

output:

3
 130 134 133

result:

ok OK

Test #28:

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

input:

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

output:

4
 5 6 7 8

result:

ok OK

Test #29:

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

input:

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

output:

6
 5 6 7 8 9 10

result:

ok OK

Test #30:

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

input:

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

output:

4
 3 4 5 6

result:

ok OK

Test #31:

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

input:

4 4 2
3 4
1 3
2 4
1 4

output:

3
 1 3 4

result:

ok OK

Test #32:

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

input:

8 12 4
1 2
3 4
5 6
7 8
2 4
2 6
4 6
1 7
2 3
4 5
6 7
1 8

output:

8
 1 2 3 4 5 6 7 8

result:

ok OK

Test #33:

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

input:

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

output:

6
 1 2 4 5 3 6

result:

ok OK

Test #34:

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

input:

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

output:

4
 4 5 9 7

result:

ok OK

Test #35:

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

input:

4 4 2
1 4
3 4
1 3
2 4

output:

3
 1 4 3

result:

ok OK

Test #36:

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

input:

101 132 34
28 60
42 56
76 86
67 71
30 41
45 50
35 96
31 48
48 83
62 70
47 82
50 98
5 40
16 54
1 17
31 88
52 80
33 36
75 86
55 83
5 15
21 100
14 31
53 82
93 101
9 71
63 92
82 93
27 39
20 100
46 66
35 82
48 86
14 98
6 85
77 92
8 38
60 84
26 79
55 67
47 55
55 89
86 93
1 64
17 18
33 85
14 46
9 69
5 78
9...

output:

4
 9 71 67 97

result:

ok OK

Test #37:

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

input:

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

output:

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

result:

ok OK

Test #38:

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

input:

150 224 75
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38
39 40
41 42
43 44
45 46
47 48
49 50
51 52
53 54
55 56
57 58
59 60
61 62
63 64
65 66
67 68
69 70
71 72
73 74
75 76
77 78
79 80
81 82
83 84
85 86
87 88
89 90
91 92
93 94
95 96
97 98
99 1...

output:

150
 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

result:

ok OK

Test #39:

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

input:

150 224 75
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38
39 40
41 42
43 44
45 46
47 48
49 50
51 52
53 54
55 56
57 58
59 60
61 62
63 64
65 66
67 68
69 70
71 72
73 74
75 76
77 78
79 80
81 82
83 84
85 86
87 88
89 90
91 92
93 94
95 96
97 98
99 1...

output:

150
 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

result:

ok OK

Test #40:

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

input:

150 223 75
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38
39 40
41 42
43 44
45 46
47 48
49 50
51 52
53 54
55 56
57 58
59 60
61 62
63 64
65 66
67 68
69 70
71 72
73 74
75 76
77 78
79 80
81 82
83 84
85 86
87 88
89 90
91 92
93 94
95 96
97 98
99 1...

output:

-1

result:

ok OK: both impossible

Test #41:

score: 0
Accepted
time: 889ms
memory: 5300kb

input:

150 10933 3
94 134
61 132
60 136
5 69
85 132
14 138
8 16
35 113
53 136
75 115
7 63
14 139
39 54
47 92
45 123
74 139
44 140
39 85
44 100
3 148
33 37
35 137
16 68
113 120
18 129
19 145
22 147
72 135
21 98
37 98
87 141
15 43
93 116
39 52
9 104
33 83
58 150
72 83
73 120
10 68
2 117
133 142
107 122
51 97...

output:

3
 148 149 150

result:

ok OK