QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#372161 | #3315. Eulerian Flight Tour | PetroTarnavskyi | WA | 1ms | 3988kb | C++20 | 4.2kb | 2024-03-31 00:29:02 | 2024-03-31 00:29:03 |
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 pair<int, int> PII;
typedef double db;
struct DSU
{
int n;
VI p, sz;
void init(int _n)
{
n = _n;
p.resize(n);
iota(ALL(p), 0);
sz.assign(n, 1);
}
int find(int v)
{
if (v == p[v])
return v;
return p[v] = find(p[v]);
}
bool unite(int u, int v)
{
u = find(u);
v = find(v);
if (u == v)
return false;
if (sz[u] > sz[v])
swap(u, v);
p[u] = v;
sz[v] += sz[u];
return true;
}
} d;
const int N = 147;
int n;
int deg[N];
int e[N][N];
int g[N][N];
int ng[N][N];
bool used[N];
bool dfs(int v, int p = -1)
{
used[v] = true;
if (p != -1 && (deg[v] & 1))
{
return true;
}
FOR (i, 0, n)
{
if (!used[i] && ng[v][i])
{
bool ok = dfs(i, v);
if (ok)
{
e[v][i] ^= 1;
e[i][v] ^= 1;
deg[v]++;
deg[i]++;
return true;
}
}
}
return false;
}
void solve()
{
vector<VI> comps(n);
FOR (i, 0, n)
{
comps[d.find(i)].PB(i);
//cerr << i << ' ' << d.find(i) << '\n';
}
VI odd;
FOR (i, 0, n)
{
auto c = comps[i];
sort(ALL(c), [&](int u, int v)
{
return (deg[u] & 1) > (deg[v] & 1);
});
if (!c.empty() && deg[c[0]] & 1)
odd.PB(i);
}
//cerr << "Odd " << SZ(odd) << '\n';
vector<PII> ans;
if (SZ(odd) == 1)
{
int j = odd[0];
int v = -1;
FOR (i, 0, n)
if (d.find(i) != j)
v = i;
for (auto u : comps[j])
{
if (deg[u] & 1)
{
d.unite(u, v);
e[v][u]++;
e[u][v]++;
}
}
}
else
{
FOR (i, 0, SZ(odd))
{
int j = odd[i];
int v = comps[j][0];
int idx = odd[(i + 1) % SZ(odd)];
int k = 1;
while (k < SZ(comps[idx]) && deg[comps[idx][k]] & 1)
{
e[v][comps[idx][k]]++;
e[comps[idx][k++]][v]++;
}
d.unite(comps[j][0], comps[idx][0]);
}
}
comps.clear();
comps.resize(n);
FOR (i, 0, n)
{
comps[d.find(i)].PB(i);
}
VI idx;
FOR (i, 0, n)
{
if (comps[i].empty())
continue;
idx.PB(i);
}
if (SZ(idx) > 2)
{
FOR (i, 0, SZ(idx))
{
int j = (i + 1) % SZ(idx);
e[comps[idx[i]][0]][comps[idx[j]][0]]++;
e[comps[idx[j]][0]][comps[idx[i]][0]]++;
}
}
else if (SZ(idx) == 2)
{
if (SZ(comps[idx[0]]) >= 2 && SZ(comps[idx[1]]) >= 2)
{
FOR (i, 0, 2)
{
FOR (j, 0, 2)
{
int u = comps[idx[0]][i];
int v = comps[idx[1]][j];
e[u][v]++;
e[v][u]++;
}
}
}
else
{
if (SZ(comps[idx[0]]) != 1)
swap(idx[0], idx[1]);
int u = comps[idx[0]][0];
int v = -1;
int w = -1;
FOR (i, 0, SZ(comps[idx[1]]))
{
FOR (j, 0, i)
{
int x = comps[idx[1]][i];
int y = comps[idx[1]][j];
if (ng[x][y])
v = x, w = y;
}
}
if (v == -1)
{
cout << -1 << '\n';
return;
}
e[u][v] ^= 1;
e[v][u] ^= 1;
e[u][w] ^= 1;
e[v][w] ^= 1;
e[w][u] ^= 1;
e[w][v] ^= 1;
}
}
FOR (i, 0, n)
{
FOR (j, 0, i)
{
// cerr << i << ' ' << j << ' ' << e[i][j] << '\n';
if (e[i][j] & 1)
{
ans.PB({j, i});
}
}
}
cout << SZ(ans) << '\n';
for (auto [u, v] : ans)
cout << u + 1 << ' ' << v + 1 << '\n';
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int m;
cin >> n >> m;
d.init(n);
FOR (i, 0, m)
{
int u, v;
cin >> u >> v;
u--, v--;
d.unite(u, v);
g[u][v] = 1;
g[v][u] = 1;
deg[u]++;
deg[v]++;
}
FOR (i, 0, n) FOR (j, 0, n)
{
if (i == j)
continue;
ng[i][j] = 1 - g[i][j];
}
if (d.sz[d.find(0)] != n)
{
solve();
return 0;
}
FOR (i, 0, n)
{
if (deg[i] & 1)
{
if (!dfs(i))
{
cout << -1 << '\n';
return 0;
}
fill(used, used + n, false);
}
}
vector<PII> ans;
FOR (i, 0, n)
{
FOR (j, 0, i)
if (e[i][j] & 1)
ans.PB({j, i});
}
cout << SZ(ans) << '\n';
for (auto [u, v] : ans)
cout << u + 1 << ' ' << v + 1 << '\n';
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3624kb
input:
11 10 1 2 2 3 3 4 4 5 6 7 7 8 8 9 9 10 10 11 6 11
output:
2 1 11 5 11
result:
ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
87 86 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 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52 53 53 54...
output:
2 1 87 43 87
result:
ok
Test #3:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
11 21 1 2 1 3 2 3 2 4 3 4 3 5 4 5 1 4 2 5 6 7 6 8 7 8 7 9 8 9 8 10 9 10 9 11 10 11 6 10 6 11 7 11
output:
2 1 11 5 11
result:
ok
Test #4:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
87 260 1 2 1 3 1 4 2 3 2 4 2 5 3 4 3 5 3 6 4 5 4 6 4 7 5 6 5 7 5 8 6 7 6 8 6 9 7 8 7 9 7 10 8 9 8 10 8 11 9 10 9 11 9 12 10 11 10 12 10 13 11 12 11 13 11 14 12 13 12 14 12 15 13 14 13 15 13 16 14 15 14 16 14 17 15 16 15 17 15 18 16 17 16 18 16 19 17 18 17 19 17 20 18 19 18 20 18 21 19 20 19 21 19 22...
output:
2 1 87 43 87
result:
ok
Test #5:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
11 9 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 1 10
output:
2 1 11 2 11
result:
ok
Test #6:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
87 85 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 52 53 53 ...
output:
2 1 87 2 87
result:
ok
Test #7:
score: 0
Accepted
time: 1ms
memory: 3860kb
input:
11 19 1 3 2 3 2 4 3 4 3 5 4 5 4 6 5 6 5 7 6 7 6 8 7 8 7 9 8 9 8 10 9 10 1 9 1 10 2 10
output:
2 1 11 2 11
result:
ok
Test #8:
score: 0
Accepted
time: 1ms
memory: 3692kb
input:
87 343 1 3 1 4 1 5 2 3 2 4 2 5 2 6 3 4 3 5 3 6 3 7 4 5 4 6 4 7 4 8 5 6 5 7 5 8 5 9 6 7 6 8 6 9 6 10 7 8 7 9 7 10 7 11 8 9 8 10 8 11 8 12 9 10 9 11 9 12 9 13 10 11 10 12 10 13 10 14 11 12 11 13 11 14 11 15 12 13 12 14 12 15 12 16 13 14 13 15 13 16 13 17 14 15 14 16 14 17 14 18 15 16 15 17 15 18 15 19...
output:
2 1 87 2 87
result:
ok
Test #9:
score: 0
Accepted
time: 1ms
memory: 3524kb
input:
11 20 5 9 4 5 4 9 1 9 1 4 4 8 1 8 1 6 6 8 8 10 6 10 3 6 3 10 2 10 2 3 3 11 2 11 2 5 5 11 9 11
output:
3 7 10 7 11 10 11
result:
ok
Test #10:
score: 0
Accepted
time: 1ms
memory: 3964kb
input:
87 344 38 45 45 70 45 75 45 72 38 70 38 75 38 72 35 38 70 75 70 72 35 70 47 70 72 75 35 75 47 75 4 75 35 72 47 72 4 72 23 72 35 47 4 35 23 35 35 85 4 47 23 47 47 85 47 82 4 23 4 85 4 82 2 4 23 85 23 82 2 23 13 23 82 85 2 85 13 85 80 85 2 82 13 82 80 82 57 82 2 13 2 80 2 57 2 15 13 80 13 57 13 15 13 ...
output:
3 54 86 54 87 86 87
result:
ok
Test #11:
score: 0
Accepted
time: 1ms
memory: 3772kb
input:
100 4850 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62...
output:
2 23 47 23 91
result:
ok
Test #12:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
100 4849 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62...
output:
4 24 45 24 75 24 76 24 98
result:
ok
Test #13:
score: 0
Accepted
time: 1ms
memory: 3664kb
input:
100 4848 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 60 1 61 1 62...
output:
6 6 59 25 59 35 59 49 59 59 68 59 69
result:
ok
Test #14:
score: 0
Accepted
time: 1ms
memory: 3968kb
input:
100 4804 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 59 1 60 1 61 1 62 1 63 1 64...
output:
46 1 57 4 57 8 57 9 57 10 57 13 57 14 57 16 57 18 57 19 57 21 57 22 57 24 57 25 57 26 57 29 57 33 57 35 57 36 57 37 57 38 57 41 57 42 57 47 57 48 57 57 58 57 60 57 61 57 63 57 65 57 66 57 69 57 71 57 72 57 73 57 74 57 75 57 77 57 78 57 79 57 86 57 89 57 90 57 93 57 95 57 99
result:
ok
Test #15:
score: 0
Accepted
time: 1ms
memory: 3752kb
input:
100 4801 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 58 1 59 1 60 1 61 1 62 1 63...
output:
40 1 20 2 20 3 20 5 20 12 20 14 20 15 20 16 20 19 20 20 21 20 22 20 24 20 28 20 29 20 30 20 32 20 34 20 36 20 37 20 38 20 40 20 44 20 47 20 50 20 53 20 55 20 57 20 59 20 66 20 68 20 69 20 70 20 72 20 78 20 82 20 89 20 91 20 93 20 96 20 100
result:
ok
Test #16:
score: 0
Accepted
time: 1ms
memory: 3600kb
input:
10 36 1 2 1 3 1 5 1 6 1 7 1 8 1 9 1 10 2 3 2 5 2 6 2 7 2 8 2 9 2 10 3 5 3 6 3 7 3 8 3 9 3 10 5 6 5 7 5 8 5 9 5 10 6 7 6 8 6 9 6 10 7 8 7 9 7 10 8 9 8 10 9 10
output:
-1
result:
ok
Test #17:
score: 0
Accepted
time: 0ms
memory: 3904kb
input:
100 4851 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61...
output:
-1
result:
ok
Test #18:
score: 0
Accepted
time: 1ms
memory: 3896kb
input:
9 28 1 2 1 3 1 4 1 6 1 7 1 8 1 9 2 3 2 4 2 6 2 7 2 8 2 9 3 4 3 6 3 7 3 8 3 9 4 6 4 7 4 8 4 9 6 7 6 8 6 9 7 8 7 9 8 9
output:
8 1 5 2 5 3 5 4 5 5 6 5 7 5 8 5 9
result:
ok
Test #19:
score: 0
Accepted
time: 1ms
memory: 3748kb
input:
99 4753 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 ...
output:
98 1 81 2 81 3 81 4 81 5 81 6 81 7 81 8 81 9 81 10 81 11 81 12 81 13 81 14 81 15 81 16 81 17 81 18 81 19 81 20 81 21 81 22 81 23 81 24 81 25 81 26 81 27 81 28 81 29 81 30 81 31 81 32 81 33 81 34 81 35 81 36 81 37 81 38 81 39 81 40 81 41 81 42 81 43 81 44 81 45 81 46 81 47 81 48 81 49 81 50 81 51 81 ...
result:
ok
Test #20:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
96 0
output:
96 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 52 53 53...
result:
ok
Test #21:
score: 0
Accepted
time: 1ms
memory: 3984kb
input:
97 0
output:
97 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 52 53 53...
result:
ok
Test #22:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
10 40 1 2 1 3 1 4 1 6 1 7 1 8 1 9 1 10 2 4 2 5 2 6 2 7 2 8 2 9 2 10 3 4 3 5 3 6 3 7 3 8 3 9 3 10 4 5 4 7 4 8 4 9 4 10 5 6 5 7 5 8 5 9 5 10 6 7 6 8 6 9 6 10 7 9 7 10 8 9 8 10
output:
0
result:
ok
Test #23:
score: 0
Accepted
time: 1ms
memory: 3632kb
input:
20 148 1 2 1 4 1 6 1 7 1 8 1 9 1 10 1 11 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 2 3 2 4 2 5 2 6 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 3 4 3 6 3 7 3 8 3 9 3 10 3 11 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 4 5 4 6 4 7 4 9 4 11 4 12 4 16 4 17 4 19 5 6 5 7 5 8 5 9 5 10 5 11 5 1...
output:
0
result:
ok
Test #24:
score: 0
Accepted
time: 1ms
memory: 3636kb
input:
30 348 1 2 1 3 1 4 1 5 1 6 1 8 1 9 1 10 1 11 1 12 1 13 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 24 1 26 1 27 1 28 1 29 1 30 2 3 2 4 2 6 2 7 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 18 2 20 2 21 2 22 2 23 2 24 2 25 2 28 2 29 2 30 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 ...
output:
0
result:
ok
Test #25:
score: 0
Accepted
time: 1ms
memory: 3612kb
input:
40 516 1 2 1 4 1 6 1 7 1 8 1 9 1 13 1 15 1 17 1 18 1 19 1 21 1 22 1 23 1 25 1 32 1 34 1 35 1 36 1 37 2 3 2 4 2 5 2 6 2 7 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 37 2 38 2 39 2 40 3 4 3 6 3 7 3 8 3 9 3 13 3 15 ...
output:
0
result:
ok
Test #26:
score: 0
Accepted
time: 1ms
memory: 3924kb
input:
50 960 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 12 1 13 1 16 1 17 1 18 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 33 1 35 1 36 1 38 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 50 2 3 2 5 2 7 2 8 2 10 2 11 2 12 2 14 2 15 2 17 2 18 2 19 2 20 2 22 2 23 2 24 2 25 2 27 2 28 2 29 2 30 2 31 2 32 ...
output:
0
result:
ok
Test #27:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
4 2 1 2 2 3
output:
2 1 4 3 4
result:
ok
Test #28:
score: 0
Accepted
time: 1ms
memory: 3616kb
input:
4 3 1 2 2 3 1 3
output:
-1
result:
ok
Test #29:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
4 3 1 2 2 3 3 4
output:
1 1 4
result:
ok
Test #30:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
4 2 2 3 3 4
output:
2 1 2 1 4
result:
ok
Test #31:
score: 0
Accepted
time: 1ms
memory: 3812kb
input:
4 2 3 4 1 4
output:
2 1 2 2 3
result:
ok
Test #32:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
4 2 1 4 1 2
output:
2 2 3 3 4
result:
ok
Test #33:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
98 4753 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 ...
output:
-1
result:
ok
Test #34:
score: 0
Accepted
time: 1ms
memory: 3724kb
input:
99 4851 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 ...
output:
0
result:
ok
Test #35:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
10 31 1 2 1 4 1 5 1 6 1 7 1 8 2 4 2 5 2 6 2 8 2 10 3 4 3 5 3 6 3 7 3 9 3 10 4 6 4 8 4 9 4 10 5 6 5 8 5 10 6 7 6 9 7 8 7 9 7 10 8 9 9 10
output:
7 1 3 2 3 4 5 2 7 5 7 1 10 6 10
result:
ok
Test #36:
score: 0
Accepted
time: 1ms
memory: 3988kb
input:
100 4801 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62 1 63...
output:
72 4 13 5 14 6 15 6 16 2 20 1 26 18 27 19 28 9 30 5 33 8 34 1 35 25 36 34 36 12 37 20 37 9 40 11 41 10 42 39 43 17 44 27 44 3 47 42 47 11 48 15 50 31 50 25 52 43 52 17 53 45 53 46 54 19 56 51 56 49 57 3 58 18 58 2 59 10 59 31 60 51 60 23 61 39 61 23 65 32 65 28 67 57 67 32 68 48 68 7 69 29 69 46 71 ...
result:
ok
Test #37:
score: 0
Accepted
time: 1ms
memory: 3780kb
input:
100 4803 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62 1 63 1 64...
output:
69 8 14 10 16 7 21 5 22 13 23 9 24 14 25 25 26 1 29 6 29 1 30 10 35 30 36 17 44 12 45 23 45 6 46 35 46 2 47 15 49 41 50 44 52 24 53 32 53 21 54 47 54 32 55 38 55 2 56 16 56 15 57 26 58 4 60 40 60 3 61 20 61 11 62 37 62 40 63 36 65 11 67 20 68 42 68 12 69 67 69 3 72 65 72 37 73 4 74 5 74 52 75 63 75 ...
result:
ok
Test #38:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
92 4049 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62 ...
output:
-1
result:
ok
Test #39:
score: 0
Accepted
time: 1ms
memory: 3808kb
input:
92 4005 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62 1 63 ...
output:
-1
result:
ok
Test #40:
score: 0
Accepted
time: 1ms
memory: 3756kb
input:
93 4143 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62 ...
output:
65 7 11 9 13 8 15 10 18 13 19 10 20 2 21 16 21 12 26 8 27 10 28 10 33 14 33 1 38 28 38 8 44 32 44 15 47 39 48 7 51 29 51 13 54 30 54 32 54 40 57 46 57 51 58 35 59 35 60 55 60 5 61 46 63 55 63 36 64 38 64 39 66 19 68 22 68 40 68 13 69 42 69 9 70 24 70 30 70 50 73 52 73 70 74 8 75 52 75 54 75 20 76 42...
result:
ok
Test #41:
score: 0
Accepted
time: 1ms
memory: 3676kb
input:
93 4096 1 2 1 3 1 4 1 5 1 6 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 61 1 62 1 63 1 64...
output:
70 1 7 3 18 1 20 18 24 13 27 23 29 15 31 16 32 22 32 24 32 30 32 14 34 5 38 8 42 5 43 31 45 26 46 7 47 18 47 19 47 27 48 21 50 11 51 37 51 11 52 44 52 13 54 28 55 45 56 6 57 15 57 29 58 53 58 39 59 40 59 3 60 33 61 8 62 29 63 33 64 27 65 39 65 31 69 46 70 44 71 34 72 35 72 41 72 35 74 14 75 35 76 8 ...
result:
ok
Test #42:
score: 0
Accepted
time: 1ms
memory: 3724kb
input:
94 140 76 94 13 94 43 62 61 93 10 88 42 68 29 79 3 70 34 50 75 78 2 25 14 34 20 28 10 78 5 33 29 86 10 37 41 66 68 94 16 21 10 72 20 82 38 61 6 67 65 68 35 79 61 87 43 85 23 56 51 75 28 75 37 89 48 72 74 82 12 67 25 62 58 61 52 54 38 58 16 76 27 83 17 69 7 28 2 42 47 83 34 89 86 91 59 89 6 8 10 65 6...
output:
61 1 90 3 90 4 90 5 90 6 90 7 90 9 90 10 90 11 90 13 90 14 90 16 90 17 90 19 90 20 90 22 90 23 90 24 90 25 90 26 90 27 90 29 90 30 90 33 90 38 90 40 90 41 90 42 90 43 90 44 90 48 90 49 90 50 90 52 90 56 90 57 90 62 90 64 90 65 90 66 90 68 90 69 90 70 90 71 90 72 90 73 90 74 90 75 90 80 90 81 90 83 9...
result:
ok
Test #43:
score: 0
Accepted
time: 1ms
memory: 3776kb
input:
94 184 72 88 43 75 15 88 21 49 58 73 2 43 68 89 39 88 15 53 7 82 18 50 25 63 35 90 26 28 9 84 37 70 18 56 38 90 8 10 47 52 43 50 28 94 24 25 66 83 26 66 35 42 3 14 47 77 2 74 9 49 4 86 47 80 52 53 53 77 1 10 47 48 58 72 2 7 37 42 28 50 64 93 13 22 1 41 54 80 53 58 62 67 16 75 2 63 1 56 17 82 11 79 4...
output:
50 1 60 4 60 6 60 9 60 10 60 12 60 13 60 14 60 15 60 16 60 17 60 21 60 25 60 29 60 31 60 32 60 35 60 36 60 37 60 40 60 41 60 42 60 44 60 45 60 47 60 48 60 50 60 51 60 54 60 55 60 56 60 57 60 60 61 60 62 60 67 60 69 60 71 60 73 60 74 60 75 60 80 60 81 60 82 60 86 60 87 60 88 60 89 60 91 60 93 60 94
result:
ok
Test #44:
score: -100
Wrong Answer
time: 1ms
memory: 3936kb
input:
95 141 83 92 15 69 44 84 8 22 3 45 46 60 36 71 71 73 9 53 89 95 13 57 8 13 7 57 62 69 12 93 6 55 32 72 28 58 3 22 5 20 14 35 52 63 28 55 48 55 43 91 19 34 31 60 5 91 39 73 5 71 44 78 26 59 42 75 45 82 36 46 31 41 54 61 16 74 55 62 15 33 31 37 41 55 59 92 54 79 28 61 61 65 37 94 4 31 35 41 21 92 40 9...
output:
9 25 30 30 38 2 49 3 49 1 51 38 51 1 76 1 77 25 77
result:
wrong answer WRONG ANSWER Non-even degree node: 1 d=5