답안 #198002

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
198002 2020-01-24T13:02:35 Z model_code Checker (COCI19_checker) C++17
110 / 110
204 ms 7044 KB
#include <bits/stdc++.h>
using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<

#define fi first
#define se second
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const string CORRECT = "tocno";
const string WRONG_TRIANGULATION = "neispravna triangulacija";
const string WRONG_COLORING = "neispravno bojenje";

const int MAXN = 2e5 + 10;

int n;
pii nxt[MAXN];
pair<pii, int> diagonals[MAXN * 2];

int dist(int a, int b) {
    return (b + n - a) % n;
}

bool cmp(const pair<pii, int>& a, const pair<pii, int>& b) {
    return dist(a.fi.fi, a.fi.se) < dist(b.fi.fi, b.fi.se);
}

bool check_triangle(int a, int b, int c) {
    return a + b + c == 6 && a != b;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin >> t;

    cin >> n;
    string colors;
    cin >> colors;
    for (int i = 0; i < n; i++) {
        nxt[i] = {(i + 1) % n, colors[i] - '0'};
    }

    for (int i = 0; i < n - 3; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;

        diagonals[2 * i] = {{a, b}, c};
        diagonals[2 * i + 1] = {{b, a}, c};
    }

    int m = 2 * (n - 3);
    sort(diagonals, diagonals + m, cmp);

    bool coloring = true;

    for (int i = 0; i < n - 2; i++) {
        int a = diagonals[i].fi.fi;
        int b = nxt[a].fi;
        int c = diagonals[i].fi.se;

        int color_a = nxt[a].se;
        int color_b = nxt[b].se;
        int color_c = diagonals[i].se;

        if (nxt[b].fi != c) {
            cout << WRONG_TRIANGULATION << "\n";
            return 0;
        }

        coloring &= check_triangle(color_a, color_b, color_c);

        nxt[a] = {c, color_c};
    }

    if (!coloring) {
        cout << WRONG_COLORING << "\n";
    } else {
        cout << CORRECT << "\n";
    }

    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 160 ms 6864 KB Output is correct
2 Correct 159 ms 6916 KB Output is correct
3 Correct 159 ms 7044 KB Output is correct
4 Correct 158 ms 6916 KB Output is correct
5 Correct 160 ms 7044 KB Output is correct
6 Correct 202 ms 6976 KB Output is correct
7 Correct 199 ms 6936 KB Output is correct
8 Correct 195 ms 6888 KB Output is correct
9 Correct 200 ms 6912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 159 ms 6916 KB Output is correct
2 Correct 159 ms 6916 KB Output is correct
3 Correct 159 ms 6916 KB Output is correct
4 Correct 158 ms 6916 KB Output is correct
5 Correct 158 ms 6916 KB Output is correct
6 Correct 197 ms 6936 KB Output is correct
7 Correct 198 ms 6980 KB Output is correct
8 Correct 201 ms 6900 KB Output is correct
9 Correct 201 ms 7044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 424 KB Output is correct
15 Correct 160 ms 6864 KB Output is correct
16 Correct 159 ms 6916 KB Output is correct
17 Correct 159 ms 7044 KB Output is correct
18 Correct 158 ms 6916 KB Output is correct
19 Correct 160 ms 7044 KB Output is correct
20 Correct 202 ms 6976 KB Output is correct
21 Correct 199 ms 6936 KB Output is correct
22 Correct 195 ms 6888 KB Output is correct
23 Correct 200 ms 6912 KB Output is correct
24 Correct 159 ms 6916 KB Output is correct
25 Correct 159 ms 6916 KB Output is correct
26 Correct 159 ms 6916 KB Output is correct
27 Correct 158 ms 6916 KB Output is correct
28 Correct 158 ms 6916 KB Output is correct
29 Correct 197 ms 6936 KB Output is correct
30 Correct 198 ms 6980 KB Output is correct
31 Correct 201 ms 6900 KB Output is correct
32 Correct 201 ms 7044 KB Output is correct
33 Correct 159 ms 6900 KB Output is correct
34 Correct 158 ms 7044 KB Output is correct
35 Correct 161 ms 6948 KB Output is correct
36 Correct 157 ms 6892 KB Output is correct
37 Correct 158 ms 6916 KB Output is correct
38 Correct 160 ms 6952 KB Output is correct
39 Correct 160 ms 6892 KB Output is correct
40 Correct 204 ms 6888 KB Output is correct
41 Correct 199 ms 6836 KB Output is correct
42 Correct 195 ms 6916 KB Output is correct
43 Correct 201 ms 6916 KB Output is correct