QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#18760#1645. 3-coloringsxiaojifangAC ✓0ms3656kbC++201.4kb2022-01-26 14:52:072022-05-06 02:26:09

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-06 02:26:09]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3656kb
  • [2022-01-26 14:52:07]
  • 提交

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;
}

详细

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