QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#18760 | #1645. 3-colorings | xiaojifang | AC ✓ | 0ms | 3656kb | C++20 | 1.4kb | 2022-01-26 14:52:07 | 2022-05-06 02:26:09 |
Judging History
answer
#include <bits/stdc++.h>
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n = 19;
std::vector<std::pair<int, int>> edges;
edges.emplace_back(0, 1);
edges.emplace_back(1, 2);
edges.emplace_back(2, 0);
for (int i = 3; i < 3 + 8; i++) {
edges.emplace_back(i, (i + 2) % 3);
if (i > 3) {
edges.emplace_back(i - 1, i);
}
}
std::cout << n << " " << edges.size() << "\n";
for (auto [u, v] : edges) {
std::cout << u + 1 << " " << v + 1 << "\n";
}
for (int k = 1; k <= 500; k++) {
edges.clear();
int x = k;
int cur = 3 + 8;
while (x % 2 == 0) {
edges.emplace_back(cur++, 0);
x /= 2;
}
int b = __builtin_popcount(x);
edges.emplace_back(b + 2, (b + 2) % 3);
int v = 3;
for (int i = 1; (1 << i) <= x; i++) {
edges.emplace_back(cur, v);
edges.emplace_back(cur++, v % 3);
if (x >> i & 1) {
v++;
}
}
assert(cur <= n);
assert(edges.size() <= 17);
while (cur < n) {
edges.emplace_back(cur, 0);
edges.emplace_back(cur++, 1);
}
std::cout << edges.size() << "\n";
for (auto [u, v] : edges) {
std::cout << u + 1 << " " << v + 1 << "\n";
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3656kb
input:
1
output:
19 18 1 2 2 3 3 1 4 3 5 1 4 5 6 2 5 6 7 3 6 7 8 1 7 8 9 2 8 9 10 3 9 10 11 1 10 11 17 4 1 12 1 12 2 13 1 13 2 14 1 14 2 15 1 15 2 16 1 16 2 17 1 17 2 18 1 18 2 19 1 19 2 16 12 1 4 1 13 1 13 2 14 1 14 2 15 1 15 2 16 1 16 2 17 1 17 2 18 1 18 2 19 1 19 2 17 5 2 12 4 12 1 13 1 13 2 14 1 14 2 15 1 15 2 1...
result:
ok Correct