Submission #205986

# Submission time Handle Problem Language Result Execution time Memory
205986 2020-03-01T18:25:43 Z rzbt Checker (COCI19_checker) C++14
110 / 110
963 ms 76276 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define MAXN 200005
typedef long long ll;


using namespace std;

int n;
set<pair<int,int> > graf[MAXN];
map<pair<int,int>, int> grane;
char s[MAXN];
int a,b,boja;

inline pair<int,int> ugranu(int a,int b){
    return mp(min(a,b),max(a,b));
}

queue<int> usi;
int bojenje=0;
int main()
{
    scanf("%*d");
    scanf("%d", &n);
    scanf("%s",s);
    for(int i=1;i<n;i++){
        a=i;
        b=i+1;
        boja=s[i-1]-'0';
        graf[a].insert(mp(b,boja));
        graf[b].insert(mp(a,boja));
        grane[ugranu(a,b)]=boja;
    }
    a=n;
    b=1;
    boja=s[n-1]-'0';
    graf[a].insert(mp(b,boja));
    graf[b].insert(mp(a,boja));
    grane[ugranu(a,b)]=boja;
    for(int i=1;i<=n-3;i++){
        scanf("%d %d %d", &a, &b, &boja);
        graf[a].insert(mp(b,boja));
        graf[b].insert(mp(a,boja));
        grane[ugranu(a,b)]=boja;
    }
    for(int i=1;i<=n;i++){
        if(graf[i].size()==2)usi.push(i);
    }
    while(!usi.empty() && n>=3){
        int t=usi.front();

        usi.pop();
        pair<int,int> prva=*graf[t].begin();
        graf[t].erase(graf[t].begin());
        pair<int,int> druga=*graf[t].begin();
        auto f=grane.find(ugranu(prva.first,druga.first));
        if(f==grane.end()){
            printf("neispravna triangulacija");
            return 0;
        }
        //printf("   %d %d %d     %d %d %d\n",t,prva.F,druga.F,prva.S,druga.S,(f->second));
        int bxor=prva.S^druga.S^(f->second);
        bojenje|=bxor;
        graf[prva.F].erase(mp(t,prva.S));
        graf[druga.F].erase(mp(t,druga.S));
        if(graf[prva.F].size()==2)usi.push(prva.F);
        if(graf[druga.F].size()==2)usi.push(druga.F);
        n--;
    }
    if(bojenje)return 0*printf("neispravno bojenje");

    printf("tocno");



    return 0;
}

Compilation message

checker.cpp: In function 'int main()':
checker.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%*d");
     ~~~~~^~~~~~~
checker.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
checker.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s",s);
     ~~~~~^~~~~~~~
checker.cpp:45:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d", &a, &b, &boja);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 11 ms 9720 KB Output is correct
2 Correct 11 ms 9720 KB Output is correct
3 Correct 11 ms 9720 KB Output is correct
4 Correct 11 ms 9720 KB Output is correct
5 Correct 12 ms 9720 KB Output is correct
6 Correct 11 ms 9720 KB Output is correct
7 Correct 11 ms 9720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 9720 KB Output is correct
2 Correct 11 ms 9720 KB Output is correct
3 Correct 11 ms 9720 KB Output is correct
4 Correct 11 ms 9720 KB Output is correct
5 Correct 12 ms 9720 KB Output is correct
6 Correct 11 ms 9720 KB Output is correct
7 Correct 11 ms 9720 KB Output is correct
8 Correct 14 ms 10360 KB Output is correct
9 Correct 14 ms 10360 KB Output is correct
10 Correct 13 ms 10360 KB Output is correct
11 Correct 13 ms 10360 KB Output is correct
12 Correct 14 ms 10360 KB Output is correct
13 Correct 14 ms 10360 KB Output is correct
14 Correct 14 ms 10360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 950 ms 76044 KB Output is correct
2 Correct 963 ms 76016 KB Output is correct
3 Correct 900 ms 75896 KB Output is correct
4 Correct 668 ms 76024 KB Output is correct
5 Correct 665 ms 75896 KB Output is correct
6 Correct 876 ms 75720 KB Output is correct
7 Correct 691 ms 75776 KB Output is correct
8 Correct 692 ms 75896 KB Output is correct
9 Correct 663 ms 75896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 953 ms 75896 KB Output is correct
2 Correct 950 ms 75920 KB Output is correct
3 Correct 925 ms 75788 KB Output is correct
4 Correct 942 ms 75896 KB Output is correct
5 Correct 949 ms 75952 KB Output is correct
6 Correct 797 ms 75768 KB Output is correct
7 Correct 720 ms 75640 KB Output is correct
8 Correct 846 ms 75596 KB Output is correct
9 Correct 671 ms 75640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 9720 KB Output is correct
2 Correct 11 ms 9720 KB Output is correct
3 Correct 11 ms 9720 KB Output is correct
4 Correct 11 ms 9720 KB Output is correct
5 Correct 12 ms 9720 KB Output is correct
6 Correct 11 ms 9720 KB Output is correct
7 Correct 11 ms 9720 KB Output is correct
8 Correct 14 ms 10360 KB Output is correct
9 Correct 14 ms 10360 KB Output is correct
10 Correct 13 ms 10360 KB Output is correct
11 Correct 13 ms 10360 KB Output is correct
12 Correct 14 ms 10360 KB Output is correct
13 Correct 14 ms 10360 KB Output is correct
14 Correct 14 ms 10360 KB Output is correct
15 Correct 950 ms 76044 KB Output is correct
16 Correct 963 ms 76016 KB Output is correct
17 Correct 900 ms 75896 KB Output is correct
18 Correct 668 ms 76024 KB Output is correct
19 Correct 665 ms 75896 KB Output is correct
20 Correct 876 ms 75720 KB Output is correct
21 Correct 691 ms 75776 KB Output is correct
22 Correct 692 ms 75896 KB Output is correct
23 Correct 663 ms 75896 KB Output is correct
24 Correct 953 ms 75896 KB Output is correct
25 Correct 950 ms 75920 KB Output is correct
26 Correct 925 ms 75788 KB Output is correct
27 Correct 942 ms 75896 KB Output is correct
28 Correct 949 ms 75952 KB Output is correct
29 Correct 797 ms 75768 KB Output is correct
30 Correct 720 ms 75640 KB Output is correct
31 Correct 846 ms 75596 KB Output is correct
32 Correct 671 ms 75640 KB Output is correct
33 Correct 931 ms 75856 KB Output is correct
34 Correct 935 ms 75816 KB Output is correct
35 Correct 883 ms 75768 KB Output is correct
36 Correct 656 ms 75896 KB Output is correct
37 Correct 927 ms 76276 KB Output is correct
38 Correct 946 ms 76152 KB Output is correct
39 Correct 928 ms 76024 KB Output is correct
40 Correct 868 ms 75768 KB Output is correct
41 Correct 738 ms 75640 KB Output is correct
42 Correct 714 ms 75864 KB Output is correct
43 Correct 830 ms 75900 KB Output is correct