Submission #222382

# Submission time Handle Problem Language Result Execution time Memory
222382 2020-04-13T06:07:30 Z tqbfjotld Checker (COCI19_checker) C++14
110 / 110
147 ms 16472 KB
#include <bits/stdc++.h>
using namespace std;

    int n;
vector<pair<pair<int,int>,int> > sides;

int iterate(int pos){
    int a = sides[pos].first.first;
    int b = -sides[pos].first.second;
    if (pos==sides.size()-1){
        return pos;
    }
    if (sides[pos+1].first.first==b){
        return pos;
    }
    if (sides[pos+1].first.first!=a){
        return -1;
    }
    int res = iterate(pos+1);
    if (res==-1) return -1;
    if (-sides[res+1].first.second!=b){
        return -1;
    }
    int res2 = iterate(res+1);
    if (res2==-1){
        return -1;
    }
    return res2;
}

int iterate2(int pos){
    int a = sides[pos].first.first;
    int b = -sides[pos].first.second;
    if (pos==sides.size()-1){
        return pos;
    }
    if (sides[pos+1].first.first==b){
        return pos;
    }
    int res = iterate2(pos+1);
    if (res==-1) return -1;

    int res2 = iterate2(res+1);
    if (res2==-1){
        return -1;
    }
    //printf("triangle of (%d,%d),(%d,%d),(%d,%d)\n",a,b,sides[pos+1].first.first,sides[pos+1].first.second,sides[res+1].first.first,sides[res+1].first.second);
    if (sides[pos].second==sides[pos+1].second) return -1;
    if (sides[pos].second==sides[res+1].second) return -1;
    if (sides[pos+1].second==sides[res+1].second) return -1;
    //printf("sides %d %d %d\n",sides[pos].second,sides[pos+1].second,sides[res+1].second);
    return res2;
}

int main(){
    int subtask;
    scanf("%d",&subtask);
    scanf("%d",&n);
    for (int x = 0; x<n; x++){
        char c;
        scanf(" %c",&c);
        if (x!=n-1){
            sides.push_back({{x+1,-x-2},c-'0'});
        }
        else{
            sides.push_back({{1,-n},c-'0'});
        }
    }
    for (int x = 0; x<n-3; x++){
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        if (b<a) swap(a,b);
        if (a+1==b){
            printf("neispravna triangulacija");
            return 0;
        }

        sides.push_back({{a,-b},c});
    }
    sort(sides.begin(),sides.end());
    for (int x = 1; x<sides.size(); x++){
        if (sides[x].first==sides[x-1].first){
            printf("neispravna triangulacija");
            return 0;
        }
    }
    if (iterate(0)==-1){
        printf("neispravna triangulacija");
        return 0;
    }
    if (iterate2(0)==-1){
        printf("neispravno bojenje");
    }
    else{
        printf("tocno");
    }

}

Compilation message

checker.cpp: In function 'int iterate(int)':
checker.cpp:10:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (pos==sides.size()-1){
         ~~~^~~~~~~~~~~~~~~~
checker.cpp: In function 'int iterate2(int)':
checker.cpp:34:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (pos==sides.size()-1){
         ~~~^~~~~~~~~~~~~~~~
checker.cpp:32:9: warning: unused variable 'a' [-Wunused-variable]
     int a = sides[pos].first.first;
         ^
checker.cpp: In function 'int main()':
checker.cpp:81:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int x = 1; x<sides.size(); x++){
                     ~^~~~~~~~~~~~~
checker.cpp:57:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&subtask);
     ~~~~~^~~~~~~~~~~~~~~
checker.cpp:58:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
checker.cpp:61:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %c",&c);
         ~~~~~^~~~~~~~~~
checker.cpp:71:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d",&a,&b,&c);
         ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 9 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 9 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 6 ms 512 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 142 ms 6628 KB Output is correct
2 Correct 147 ms 8412 KB Output is correct
3 Correct 140 ms 8276 KB Output is correct
4 Correct 136 ms 8280 KB Output is correct
5 Correct 136 ms 8280 KB Output is correct
6 Correct 135 ms 13020 KB Output is correct
7 Correct 143 ms 13912 KB Output is correct
8 Correct 132 ms 8280 KB Output is correct
9 Correct 131 ms 8280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 144 ms 6628 KB Output is correct
2 Correct 141 ms 8408 KB Output is correct
3 Correct 147 ms 8408 KB Output is correct
4 Correct 142 ms 8408 KB Output is correct
5 Correct 139 ms 8280 KB Output is correct
6 Correct 137 ms 16472 KB Output is correct
7 Correct 144 ms 15676 KB Output is correct
8 Correct 135 ms 12076 KB Output is correct
9 Correct 143 ms 13912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 9 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 6 ms 512 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 142 ms 6628 KB Output is correct
16 Correct 147 ms 8412 KB Output is correct
17 Correct 140 ms 8276 KB Output is correct
18 Correct 136 ms 8280 KB Output is correct
19 Correct 136 ms 8280 KB Output is correct
20 Correct 135 ms 13020 KB Output is correct
21 Correct 143 ms 13912 KB Output is correct
22 Correct 132 ms 8280 KB Output is correct
23 Correct 131 ms 8280 KB Output is correct
24 Correct 144 ms 6628 KB Output is correct
25 Correct 141 ms 8408 KB Output is correct
26 Correct 147 ms 8408 KB Output is correct
27 Correct 142 ms 8408 KB Output is correct
28 Correct 139 ms 8280 KB Output is correct
29 Correct 137 ms 16472 KB Output is correct
30 Correct 144 ms 15676 KB Output is correct
31 Correct 135 ms 12076 KB Output is correct
32 Correct 143 ms 13912 KB Output is correct
33 Correct 142 ms 8408 KB Output is correct
34 Correct 144 ms 8408 KB Output is correct
35 Correct 138 ms 8408 KB Output is correct
36 Correct 138 ms 8432 KB Output is correct
37 Correct 142 ms 8408 KB Output is correct
38 Correct 141 ms 8280 KB Output is correct
39 Correct 138 ms 8280 KB Output is correct
40 Correct 136 ms 13528 KB Output is correct
41 Correct 137 ms 16348 KB Output is correct
42 Correct 128 ms 8316 KB Output is correct
43 Correct 133 ms 11864 KB Output is correct