답안 #516722

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
516722 2022-01-22T03:32:37 Z KoD Trobojnica (COCI19_trobojnica) C++17
0 / 110
2000 ms 208 KB
#include <bits/stdc++.h>

using std::vector;
using std::array;
using std::pair;
using std::tuple;

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int N;
    std::cin >> N;
    vector<int> id(N), label(N), next(N);
    for (int i = 0; i < N; ++i) {
        char c;
        std::cin >> c;
        id[i] = i;
        label[i] = c - '1';
        next[i] = i + 1 == N ? 0 : i + 1;
    }
    array<int, 3> count = {};
    for (const int x : label) {
        count[x] += 1;
    }
    for (const int x : count) {
        if (x == N or x % 2 != N % 2) {
            std::cout << "NE\n";
            return 0;
        }
    }
    std::cout << "DA\n";
    int root = 0;
    for (int step = 0; step < N - 3; ++step) {
        while (label[root] == label[next[root]] or (count[label[root]] == 1 and count[label[next[root]]] == 1)) {
            root = next[root];
        }
        const int x = root;
        const int y = next[x];
        const int z = next[y];
        const int c = 3 - label[x] - label[y];
        std::cout << x + 1 << ' ' << z + 1 << ' ' << c + 1 << '\n';
        next[x] = z;
        label[x] = c;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Execution timed out 2063 ms 208 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Execution timed out 2063 ms 208 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Execution timed out 2063 ms 208 KB Time limit exceeded
4 Halted 0 ms 0 KB -