Submission #205986

#TimeUsernameProblemLanguageResultExecution timeMemory
205986rzbtChecker (COCI19_checker)C++14
110 / 110
963 ms76276 KiB
#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 (stderr)

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 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...