답안 #199758

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
199758 2020-02-03T07:29:42 Z SamAnd Checker (COCI19_checker) C++17
110 / 110
1756 ms 62152 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;

int n;
char a[N];
map<int, map<int, int> > c;

int l[N], r[N];

bool stg(int x)
{
    if (c.find(l[x]) != c.end() && c[l[x]].find(r[x]) != c[l[x]].end())
        return true;
    return false;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    scanf("%d", &n);
    scanf("%d", &n);
    scanf(" %s", (a + 1));
    for (int i = 1; i < n; ++i)
    {
        c[i][i + 1] = (a[i] - '0');
        c[i + 1][i] = (a[i] - '0');
    }
    c[n][1] = (a[n] - '0');
    c[1][n] = (a[n] - '0');
    for (int i = 0; i < n - 3; ++i)
    {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        c[x][y] = z;
        c[y][x] = z;
    }
    for (int i = 1; i < n; ++i)
        r[i] = i + 1;
    r[n] = 1;
    l[1] = n;
    for (int i = 2; i <= n; ++i)
        l[i] = i - 1;
    queue<int> q;
    for (int i = 1; i <= n; ++i)
    {
        if (stg(i))
            q.push(i);
    }
    bool z = true;
    for (int ii = 0; ii < n - 3; ++ii)
    {
        if (q.empty())
        {
            printf("neispravna triangulacija\n");
            return 0;
        }
        int x = q.front();
        q.pop();
        if (!stg(x))
        {
            printf("neispravna triangulacija\n");
            return 0;
        }
        if (c[x][l[x]] == c[x][r[x]] || c[x][l[x]] == c[l[x]][r[x]] || c[x][r[x]] == c[l[x]][r[x]])
            z = false;
        r[l[x]] = r[x];
        l[r[x]] = l[x];
        if (stg(l[x]))
            q.push(l[x]);
        if (stg(r[x]))
            q.push(r[x]);
    }
    if (!z)
        printf("neispravno bojenje\n");
    else
        printf("tocno\n");
    return 0;
}

Compilation message

checker.cpp: In function 'int main()':
checker.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
checker.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
checker.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf(" %s", (a + 1));
     ~~~~~^~~~~~~~~~~~~~~~
checker.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d", &x, &y, &z);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 380 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 6 ms 472 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 248 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 380 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 6 ms 472 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 248 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
8 Correct 11 ms 888 KB Output is correct
9 Correct 11 ms 888 KB Output is correct
10 Correct 11 ms 888 KB Output is correct
11 Correct 10 ms 892 KB Output is correct
12 Correct 11 ms 1016 KB Output is correct
13 Correct 11 ms 892 KB Output is correct
14 Correct 11 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1728 ms 58760 KB Output is correct
2 Correct 1718 ms 58872 KB Output is correct
3 Correct 1706 ms 58872 KB Output is correct
4 Correct 1634 ms 61944 KB Output is correct
5 Correct 1553 ms 62012 KB Output is correct
6 Correct 1476 ms 61944 KB Output is correct
7 Correct 1354 ms 61816 KB Output is correct
8 Correct 1181 ms 61952 KB Output is correct
9 Correct 1174 ms 61816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1694 ms 58868 KB Output is correct
2 Correct 1698 ms 58836 KB Output is correct
3 Correct 1707 ms 59032 KB Output is correct
4 Correct 1749 ms 61712 KB Output is correct
5 Correct 1687 ms 61688 KB Output is correct
6 Correct 1415 ms 61688 KB Output is correct
7 Correct 1384 ms 61944 KB Output is correct
8 Correct 1446 ms 61688 KB Output is correct
9 Correct 1317 ms 61688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 380 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 6 ms 472 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 248 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
8 Correct 11 ms 888 KB Output is correct
9 Correct 11 ms 888 KB Output is correct
10 Correct 11 ms 888 KB Output is correct
11 Correct 10 ms 892 KB Output is correct
12 Correct 11 ms 1016 KB Output is correct
13 Correct 11 ms 892 KB Output is correct
14 Correct 11 ms 980 KB Output is correct
15 Correct 1728 ms 58760 KB Output is correct
16 Correct 1718 ms 58872 KB Output is correct
17 Correct 1706 ms 58872 KB Output is correct
18 Correct 1634 ms 61944 KB Output is correct
19 Correct 1553 ms 62012 KB Output is correct
20 Correct 1476 ms 61944 KB Output is correct
21 Correct 1354 ms 61816 KB Output is correct
22 Correct 1181 ms 61952 KB Output is correct
23 Correct 1174 ms 61816 KB Output is correct
24 Correct 1694 ms 58868 KB Output is correct
25 Correct 1698 ms 58836 KB Output is correct
26 Correct 1707 ms 59032 KB Output is correct
27 Correct 1749 ms 61712 KB Output is correct
28 Correct 1687 ms 61688 KB Output is correct
29 Correct 1415 ms 61688 KB Output is correct
30 Correct 1384 ms 61944 KB Output is correct
31 Correct 1446 ms 61688 KB Output is correct
32 Correct 1317 ms 61688 KB Output is correct
33 Correct 1702 ms 61944 KB Output is correct
34 Correct 1706 ms 61936 KB Output is correct
35 Correct 1660 ms 62132 KB Output is correct
36 Correct 1636 ms 61944 KB Output is correct
37 Correct 1671 ms 62072 KB Output is correct
38 Correct 1696 ms 61944 KB Output is correct
39 Correct 1756 ms 62152 KB Output is correct
40 Correct 1441 ms 61560 KB Output is correct
41 Correct 1358 ms 61688 KB Output is correct
42 Correct 1374 ms 61688 KB Output is correct
43 Correct 1447 ms 61688 KB Output is correct