Submission #222480

#TimeUsernameProblemLanguageResultExecution timeMemory
222480dantoh000Checker (COCI19_checker)C++14
110 / 110
781 ms75932 KiB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
unordered_map<int, unordered_map<int, int> > adjmat;
vector<ii> adjlist[200005];
int st, n;
vector<ii> edg;
int f1, f2;
void addedge(int a, int b, int c){
    adjmat[a][b] = adjmat[b][a] = c;
    adjlist[a].push_back({b,c});
    adjlist[b].push_back({a,c});
    if (a > b) swap(a,b);
    edg.push_back({a,b});
}
int cur;
bool cmp(ii a, ii b){
    return (n+a.first-cur)%n < (n+b.first-cur)%n;
}
int main(){
    scanf("%d",&st);
    scanf("%d",&n);
    f1 = f2 = 1;
    for (int i = 1; i <= n; i++){
        char x;
        scanf(" %c",&x);
        addedge(i,i%n+1,x-'0');
    }
    for (int i = 0; i < n-3; i++){
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        addedge(a,b,c);
    }
    for (int i = 1; i <= n; i++){
        cur = i;
        sort(adjlist[i].begin(),adjlist[i].end(),cmp);
        for (int j = 0; j < (int)adjlist[i].size()-1; j++){
            ii cur = adjlist[i][j];
            ii nx = adjlist[i][j+1];
            if (cur.second == nx.second) f2 = 0;
            int z1 = cur.first, z2 = nx.first;
            //printf("%d -> %d -> %d\n",i,z1,z2);
            if (adjmat[z1][z2] == 0) f1 = 0;
            else{
                if (cur.second + nx.second + adjmat[z1][z2] != 6) f2 = 0;
            }
        }
        for (auto x : adjlist[i]){
            //printf("<%d %d>:%d\n",i,x.first,x.second);
        }
    }
    if (f1 == 0) printf("neispravna triangulacija");
    else if (f2 == 0) printf("neispravno bojenje");
    else printf("tocno");


}

Compilation message (stderr)

checker.cpp: In function 'int main()':
checker.cpp:48:19: warning: variable 'x' set but not used [-Wunused-but-set-variable]
         for (auto x : adjlist[i]){
                   ^
checker.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&st);
     ~~~~~^~~~~~~~~~
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:26:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %c",&x);
         ~~~~~^~~~~~~~~~
checker.cpp:31: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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...