QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#528893 | #1824. Special Cycle | PetroTarnavskyi | AC ✓ | 11687ms | 6004kb | C++23 | 5.3kb | 2024-08-24 00:34:46 | 2024-08-24 00:34:46 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef double db;
const int N = 1 << 10;
vector<PII> G[N];
VI ord;
int us[N];
int n;
int bads = 0;
bool dfs(int v, int id, int it)
{
us[v] = 1;
if(v >= 2 * n && us[v ^ 1] == 1)
bads++;
ord.PB(v);
for(auto [to, ind] : G[v])
{
if(ind == id || us[to] == 2)
continue;
if(us[to] == 0)
{
if(dfs(to, ind, it))
return true;
continue;
}
if(it == 0 && bads != 0)
continue;
ord.PB(to);
return true;
}
ord.pop_back();
us[v] = 2;
if(v >= 2 * n && us[v ^ 1] == 1)
bads--;
return false;
}
VI findCycle(int sz, int v, vector<tuple<int, int, int>> edges, int it)
{
ord.clear();
fill(us, us + N, 0);
bads = 0;
FOR(i, 0, N)
G[i].clear();
for(auto [a, b, i] : edges)
G[a].PB(MP(b, i));
if(!dfs(v, -1, it))
return {};
v = ord.back();
ord.pop_back();
VI ans;
while(ord.back() != v)
{
ans.PB(ord.back());
ord.pop_back();
}
ans.PB(v);
return ans;
}
void print(VI ans)
{
cout << SZ(ans) << "\n";
for(int v : ans)
cout << v + 1 << "\n";
exit(0);
}
void check(vector<PII> badEdges, vector<tuple<int, int, int>> edges, VI ans)
{
if(SZ(ans) < 3)
return;
set<PII> eg;
for(auto [a, b] : badEdges)
{
eg.insert(MP(a, b));
eg.insert(MP(b, a));
}
for(auto [a, b, i] : edges)
eg.insert(MP(a, b));
VI ok(n), pos(n);
FOR(i, 0, SZ(ans))
{
int v = ans[i];
pos[v] = i;
if(ok[v])
return;
ok[v] = 1;
int to = ans[(i + 1) % SZ(ans)];
if(!eg.count(MP(v, to)))
return;
}
for(auto [a, b] : badEdges)
{
if(ok[a] + ok[b] == 1)
return;
if(ok[a] == 0 && ok[b] == 0)
continue;
if(pos[a] > pos[b])
swap(a, b);
if(pos[a] + 1 == pos[b] || (pos[a] == 0 && pos[b] == SZ(ans) - 1))
continue;
return;
}
print(ans);
}
VI g[N];
VI order;
bool used[N];
void dfs(int v)
{
used[v] = 1;
order.PB(v);
for(int to : g[v])
if(!used[to])
dfs(to);
}
mt19937 rng(74);
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int m, k;
cin >> n >> m >> k;
vector<PII> badEdges(k);
vector<tuple<int, int, int>> edges(2 * (m - k));
VI badV(n);
FOR(i, 0, k)
{
int a, b;
cin >> a >> b;
a--; b--;
badV[a]++;
badV[b]++;
badEdges[i] = MP(a, b);
}
FOR(i, 0, m - k)
{
int a, b;
cin >> a >> b;
a--; b--;
edges[2 * i] = {a, b, i};
edges[2 * i + 1] = {b, a, i};
}
for(auto [a, b] : badEdges)
{
g[a].PB(b);
g[b].PB(a);
}
map<PII, VI> orders;
FOR(it, 0, 2)
FOR(i, 0, n)
{
if(used[i] || badV[i] == 0)
continue;
if(it == 0 && badV[i] == 2)
continue;
order.clear();
dfs(i);
int mx = 0, mn = N;
for(int v : order)
{
mx = max(mx, badV[v]);
mn = min(mn, badV[v]);
}
if(mx == 2 && mn == 2)
print(order);
if(mx > 2)
{
for(int v : order)
badV[v] = 47;
continue;
}
int to = order.back();
orders[MP(i, to)] = order;
reverse(ALL(order));
orders[MP(to, i)] = order;
}
vector<tuple<int, int, int>> nedg;
for(auto [a, b, i] : edges)
{
if(badV[a] != 0 || badV[b] != 0)
continue;
nedg.PB({a, b, i});
}
FOR(v, 0, n)
{
VI ans = findCycle(n, v, nedg, 0);
check(badEdges, edges, ans);
}
vector<tuple<int, int, int>> edg;
for(auto [pii, _] : orders)
{
auto [a, b] = pii;
int A = 2 * n + 2 * a;
int B = 2 * n + 2 * b;
edg.PB({A, B ^ 1, SZ(edg)});
edg.PB({B, A ^ 1, SZ(edg)});
}
for(auto [a, b, _] : edges)
{
if(a > b)
continue;
if(badV[a] == 0 && badV[b] == 0)
{
int sz = SZ(edg);
edg.PB({a, b, sz});
edg.PB({b, a, sz});
continue;
}
if(badV[a] > 1 || badV[b] > 1)
continue;
if(badV[a] == 1 && badV[b] == 1)
{
int A = 2 * n + 2 * a;
int B = 2 * n + 2 * b;
edg.PB({A ^ 1, B, SZ(edg)});
edg.PB({B ^ 1, A, SZ(edg)});
continue;
}
if(badV[a] == 0)
swap(a, b);
int A = 2 * n + 2 * a;
int sz = SZ(edg);
edg.PB({A ^ 1, b, sz});
edg.PB({b, A, sz});
}
VI tot(n);
iota(ALL(tot), 0);
check(badEdges, edges, tot);
FOR(it, 0, 3000)
{
FOR(st, 0, 3 * n)
{
VI res = findCycle(3 * n, st, edg, it % 2);
if(SZ(res) == 0)
continue;
for(int& v : res)
if(v >= 2 * n)
v = (v - 2 * n) / 2;
VI ans = {res[0]};
FOR(i, 1, SZ(res))
{
int v = ans.back();
int to = res[i];
if(orders.count(MP(v, to)))
{
ans.pop_back();
VI cur = orders[MP(v, to)];
for(int x : cur)
ans.PB(x);
continue;
}
ans.PB(to);
}
int v = ans.back(), to = ans[0];
if(SZ(res) != 2 && orders.count(MP(v, to)))
{
ans.pop_back();
VI cur = orders[MP(v, to)];
for(int x : cur)
ans.PB(x);
ans.pop_back();
}
check(badEdges, edges, ans);
}
if(it % 2 == 1)
shuffle(ALL(edg), rng);
}
cout << "-1\n";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3700kb
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:
8 8 7 6 5 4 1 2 3
result:
ok OK
Test #2:
score: 0
Accepted
time: 34ms
memory: 3612kb
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: 1ms
memory: 3656kb
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 6 11 12 17 18 23 24 29 30 35 36 41 42 47 48 53 54 59 60 65 66 5
result:
ok OK
Test #4:
score: 0
Accepted
time: 1ms
memory: 3704kb
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 42 16 52 11 26 32 15 13 45
result:
ok OK
Test #5:
score: 0
Accepted
time: 1ms
memory: 3948kb
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 42 27 24 82 5 8 18
result:
ok OK
Test #6:
score: 0
Accepted
time: 1ms
memory: 3684kb
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 133 105 145 48 120 12 123 11 92 102 116 37 101 44 34 54 80 1
result:
ok OK
Test #7:
score: 0
Accepted
time: 0ms
memory: 3576kb
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 24 13 10 19 6 9 8
result:
ok OK
Test #8:
score: 0
Accepted
time: 0ms
memory: 3652kb
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:
14 4 25 43 47 37 8 11 55 18 22 1 53 59 36
result:
ok OK
Test #9:
score: 0
Accepted
time: 0ms
memory: 3588kb
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:
10 49 46 44 62 11 37 57 29 21 5
result:
ok OK
Test #10:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
6 8 1 1 4 3 6 1 6 1 2 3 5 5 6 4 6 3 4
output:
3 5 6 3
result:
ok OK
Test #11:
score: 0
Accepted
time: 68ms
memory: 3668kb
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: 253ms
memory: 3860kb
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: 207ms
memory: 3716kb
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: 23ms
memory: 3664kb
input:
3 2 1 2 3 1 3
output:
-1
result:
ok OK: both impossible
Test #15:
score: 0
Accepted
time: 141ms
memory: 3620kb
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: 232ms
memory: 3620kb
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: 0ms
memory: 3648kb
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 5 6 7 8 4 3 2 1
result:
ok OK
Test #18:
score: 0
Accepted
time: 6ms
memory: 6004kb
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:
22 45 17 82 125 111 13 67 29 30 37 18 123 8 25 15 70 122 144 100 52 23 126
result:
ok OK
Test #19:
score: 0
Accepted
time: 2ms
memory: 4236kb
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:
9 68 47 45 27 85 46 31 87 40
result:
ok OK
Test #20:
score: 0
Accepted
time: 4ms
memory: 5332kb
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:
5 44 30 25 117 94
result:
ok OK
Test #21:
score: 0
Accepted
time: 2ms
memory: 4304kb
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:
4 26 51 18 107
result:
ok OK
Test #22:
score: 0
Accepted
time: 2ms
memory: 4392kb
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:
5 60 80 10 82 67
result:
ok OK
Test #23:
score: 0
Accepted
time: 2ms
memory: 5228kb
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:
17 139 66 9 20 37 36 93 111 92 74 103 80 28 73 77 51 62
result:
ok OK
Test #24:
score: 0
Accepted
time: 4ms
memory: 4988kb
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:
6 143 88 80 61 82 13
result:
ok OK
Test #25:
score: 0
Accepted
time: 2ms
memory: 5144kb
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:
13 67 19 27 130 131 61 49 102 144 90 16 82 5
result:
ok OK
Test #26:
score: 0
Accepted
time: 4ms
memory: 5176kb
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:
20 64 99 100 14 71 31 90 65 21 112 10 5 92 34 19 136 15 55 17 2
result:
ok OK
Test #27:
score: 0
Accepted
time: 4ms
memory: 5016kb
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:
4 49 133 106 25
result:
ok OK
Test #28:
score: 0
Accepted
time: 0ms
memory: 3620kb
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:
8 5 6 10 9 4 3 2 1
result:
ok OK
Test #29:
score: 0
Accepted
time: 0ms
memory: 3668kb
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 10 9 8 7 6 5
result:
ok OK
Test #30:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
6 7 3 1 2 3 4 5 6 2 3 3 6 4 5 1 3
output:
4 6 5 4 3
result:
ok OK
Test #31:
score: 0
Accepted
time: 0ms
memory: 3676kb
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: 0ms
memory: 3912kb
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: 0ms
memory: 3608kb
input:
6 8 3 1 2 1 6 3 6 1 5 3 5 2 4 4 6 4 5
output:
6 5 3 6 1 2 4
result:
ok OK
Test #34:
score: 0
Accepted
time: 0ms
memory: 3908kb
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:
5 8 5 4 7 9
result:
ok OK
Test #35:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
4 4 2 1 4 3 4 1 3 2 4
output:
3 3 4 1
result:
ok OK
Test #36:
score: 0
Accepted
time: 1ms
memory: 3884kb
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 97 9 71 67
result:
ok OK
Test #37:
score: 0
Accepted
time: 0ms
memory: 3620kb
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: 1ms
memory: 3972kb
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: 1ms
memory: 3676kb
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: 11687ms
memory: 3960kb
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: 6ms
memory: 5776kb
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:
20 48 135 72 83 33 37 98 21 131 127 110 73 120 113 35 137 74 139 14 138
result:
ok OK