QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#616771 | #9189. Make them Meet | liuziao | 24 | 2ms | 3860kb | C++23 | 2.1kb | 2024-10-06 11:21:24 | 2024-10-06 11:21:24 |
Judging History
answer
#include <bits/stdc++.h>
// #define int int64_t
const int kMaxN = 105, kMaxM = 1e4 + 5;
int n, m;
int u[kMaxM], v[kMaxM];
std::vector<int> G[kMaxN];
namespace Sub1 {
std::vector<std::vector<int>> res;
bool check() {
if (m != n - 1) return 0;
for (int i = 1; i <= m; ++i)
if (u[i] != 1 && v[i] != 1)
return 0;
return 1;
}
void solve() {
std::vector<int> tmp;
for (int i = 1; i <= n; ++i) tmp.emplace_back(1);
res.emplace_back(tmp);
for (auto &x : tmp) x = 0;
tmp[0] = tmp[1] = 1;
res.emplace_back(tmp);
for (auto &x : tmp) x = 1;
res.emplace_back(tmp);
std::cout << res.size() << '\n';
for (auto &vec : res) {
for (auto x : vec) std::cout << x << ' ';
std::cout << '\n';
}
}
} // namespace Sub1
namespace Sub2 {
int dep[kMaxN];
bool check() {
if (m == n * (n - 1) / 2) return 1;
if (m != n - 1) return 0;
for (int i = 1; i <= m; ++i)
if (abs(u[i] - v[i]) != 1)
return 0;
return 1;
}
void dfs(int u, int fa) {
dep[u] = dep[fa] + 1;
for (auto v : G[u]) {
if (v == fa) continue;
dfs(v, u);
}
}
void solve() {
for (int i = 1; i <= m; ++i) {
G[u[i]].emplace_back(v[i]), G[v[i]].emplace_back(u[i]);
}
if (m == n - 1) {
dfs(1, 0);
} else {
for (int i = 1; i <= n; ++i) dep[i] = i;
}
std::cout << 450 << '\n';
for (int i = 1; i <= 450; ++i) {
if (i & 1) {
for (int j = 1; j <= n; ++j) {
std::cout << (dep[j] - 1) / 2 + 1 << ' ';
}
std::cout << '\n';
} else {
for (int j = 1; j <= n; ++j)
std::cout << dep[j] / 2 << ' ';
std::cout << '\n';
}
}
}
} // namespace Sub2
void dickdreamer() {
std::cin >> n >> m;
for (int i = 1; i <= m; ++i) {
std::cin >> u[i] >> v[i];
++u[i], ++v[i];
}
Sub2::solve();
}
int32_t main() {
#ifdef ORZXKR
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);
int T = 1;
// std::cin >> T;
while (T--) dickdreamer();
// std::cerr << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 0ms
memory: 3788kb
input:
2 1 0 1
output:
450 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0...
result:
points 1.0
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 3628kb
input:
3 2 0 1 0 2
output:
450 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 ...
result:
wrong answer If people start at 0 and 1, then they can avoid each other
Subtask #2:
score: 13
Accepted
Test #6:
score: 13
Accepted
time: 0ms
memory: 3824kb
input:
2 1 0 1
output:
450 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0...
result:
points 1.0
Test #7:
score: 13
Accepted
time: 0ms
memory: 3564kb
input:
3 3 1 2 0 1 0 2
output:
450 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 ...
result:
points 1.0
Test #8:
score: 13
Accepted
time: 0ms
memory: 3560kb
input:
4 6 0 1 0 3 2 3 0 2 1 3 1 2
output:
450 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 ...
result:
points 1.0
Test #9:
score: 13
Accepted
time: 0ms
memory: 3544kb
input:
10 45 4 9 2 8 5 9 1 2 2 9 4 5 5 7 6 7 1 3 1 9 3 4 0 3 4 7 0 6 5 6 7 9 4 8 6 8 0 5 1 8 3 9 1 6 6 9 4 6 0 8 2 3 0 4 0 9 0 7 3 6 0 2 2 5 3 7 3 5 7 8 5 8 8 9 0 1 2 7 1 7 1 4 2 6 2 4 3 8 1 5
output:
450 1 1 2 2 3 3 4 4 5 5 0 1 1 2 2 3 3 4 4 5 1 1 2 2 3 3 4 4 5 5 0 1 1 2 2 3 3 4 4 5 1 1 2 2 3 3 4 4 5 5 0 1 1 2 2 3 3 4 4 5 1 1 2 2 3 3 4 4 5 5 0 1 1 2 2 3 3 4 4 5 1 1 2 2 3 3 4 4 5 5 0 1 1 2 2 3 3 4 4 5 1 1 2 2 3 3 4 4 5 5 0 1 1 2 2 3 3 4 4 5 1 1 2 2 3 3 4 4 5 5 0 1 1 2 2 3 3 4 4 5 1 ...
result:
points 1.0
Test #10:
score: 13
Accepted
time: 1ms
memory: 3548kb
input:
15 105 4 10 8 13 0 12 11 12 2 13 8 14 6 10 0 4 8 12 2 12 1 13 5 9 2 8 7 10 6 13 0 13 9 13 7 11 3 13 0 3 4 7 5 13 7 13 0 7 0 11 0 8 0 2 2 4 2 6 6 9 0 1 9 11 1 9 3 14 3 4 10 11 5 10 0 9 3 9 6 11 2 10 5 6 2 5 1 14 6 8 9 12 2 11 9 10 5 12 5 14 4 14 7 14 5 8 5 7 1 12 0 14 7 9 3 11 1 8 0 10 1 3 8 9 4 6 10...
output:
450 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 0 1 1 2 2 3 3 4 4...
result:
points 1.0
Test #11:
score: 13
Accepted
time: 1ms
memory: 3560kb
input:
30 435 5 6 8 11 3 26 8 29 10 22 6 20 18 22 23 27 13 18 2 26 21 25 11 15 25 28 2 22 18 20 3 13 10 19 6 29 10 15 0 13 7 22 13 28 9 16 2 28 6 16 3 17 6 14 4 8 16 17 9 22 22 24 26 29 14 28 19 29 28 29 4 28 13 23 12 19 1 2 5 10 1 6 2 4 25 27 4 22 9 26 16 23 5 16 6 11 0 17 16 27 0 7 15 26 2 16 8 12 1 25 3...
output:
450 1 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 0 1 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 1 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 0 1 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 1 1 2 ...
result:
points 1.0
Test #12:
score: 13
Accepted
time: 1ms
memory: 3524kb
input:
40 780 21 24 11 32 12 27 19 20 3 35 25 35 32 35 27 33 0 24 1 3 1 29 14 25 8 30 24 31 14 32 7 12 5 31 28 35 7 10 18 24 13 32 1 26 3 4 10 30 14 38 22 24 9 31 5 10 17 32 2 34 28 39 3 38 13 34 6 10 0 6 9 25 11 14 13 20 10 20 18 28 6 33 34 35 29 33 16 39 4 38 3 24 20 29 17 18 33 36 13 37 24 27 12 33 5 29...
output:
450 1 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 0 1 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 1 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 1...
result:
points 1.0
Test #13:
score: 13
Accepted
time: 1ms
memory: 3860kb
input:
50 1225 6 10 14 36 0 34 7 23 22 31 18 34 2 19 13 21 0 46 0 11 2 43 2 11 13 20 13 19 7 39 35 37 9 17 31 38 13 40 7 28 2 41 20 46 25 36 12 39 1 37 21 42 33 48 10 24 13 26 26 37 0 47 17 19 1 28 28 40 15 40 11 22 10 19 24 28 12 28 19 40 6 12 13 48 20 37 11 46 8 19 5 24 16 28 15 47 31 34 11 21 28 33 14 1...
output:
450 1 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 0 1 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 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8...
result:
points 1.0
Test #14:
score: 13
Accepted
time: 2ms
memory: 3616kb
input:
100 4950 24 39 27 46 11 71 57 65 3 8 84 97 74 87 17 49 12 72 1 4 22 83 29 42 28 65 39 89 29 92 26 78 45 53 18 44 33 43 14 98 50 66 21 95 32 67 21 33 21 80 59 77 70 85 13 16 0 41 31 65 51 80 22 80 30 79 55 75 54 82 29 57 72 97 31 85 86 87 60 90 1 17 65 81 13 15 44 71 58 88 65 87 8 31 77 99 4 44 29 43...
output:
450 1 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 0 1 1 2 2 3 3...
result:
points 1.0
Subtask #3:
score: 11
Accepted
Test #15:
score: 11
Accepted
time: 0ms
memory: 3760kb
input:
2 1 0 1
output:
450 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0...
result:
points 1.0
Test #16:
score: 11
Accepted
time: 0ms
memory: 3564kb
input:
3 2 0 1 1 2
output:
450 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 1 2 0 1 1 1 ...
result:
points 1.0
Test #17:
score: 11
Accepted
time: 0ms
memory: 3560kb
input:
4 3 0 1 1 2 2 3
output:
450 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 0 1 1 2 1 1 2 2 ...
result:
points 1.0
Test #18:
score: 11
Accepted
time: 1ms
memory: 3604kb
input:
49 48 0 1 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
output:
450 1 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 0 1 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 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 1...
result:
points 1.0
Test #19:
score: 11
Accepted
time: 2ms
memory: 3496kb
input:
99 98 0 1 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:
450 1 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 0 1 1 2 2 3 3 4 ...
result:
points 1.0
Test #20:
score: 11
Accepted
time: 2ms
memory: 3492kb
input:
100 99 0 1 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 ...
output:
450 1 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 0 1 1 2 2 3 3...
result:
points 1.0
Test #21:
score: 11
Accepted
time: 1ms
memory: 3620kb
input:
64 63 0 1 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:
450 1 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 0 1 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...
result:
points 1.0
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%