제출 #167690

#제출 시각아이디문제언어결과실행 시간메모리
167690rzbtTeoretičar (COCI18_teoreticar)C++14
52 / 130
10522 ms164384 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 100005 typedef long long ll; using namespace std; int l,r,m; vector<pair<int,int> > niz[2*MAXN]; pair<int,int> grane[5*MAXN]; int boje[5*MAXN],stepen[2*MAXN]; vector<int> resip,tcvor,levi,desni; int bboja=0,maxd; bool aktivan[2*MAXN],obidjen[10*MAXN]; int pocs[2*MAXN]; void ojler(int t,int grana,int znak,int dub){ //if(t==24)printf(" euler %d %d %d\n",t,dub,grana); //printf(" %d %d %d %d\n",t,grana,znak,dub); obidjen[grana]=true; for(auto x:niz[t]) if(!obidjen[x.second]) ojler(x.first,x.second,1-znak,dub); boje[grana]|=(znak<<dub); if(znak)desni.pb(grana); else levi.pb(grana); } void resi(int dub,vector<int> v){ if(dub>=maxd)return; levi.clear(); desni.clear(); for(auto x:v){ obidjen[x]=false; int a=grane[x].F,b=grane[x].S; if(!aktivan[a]){ aktivan[a]=true; niz[a].clear(); tcvor.pb(a); } if(!aktivan[b]){ aktivan[b]=true; niz[b].clear(); tcvor.pb(b); } niz[a].pb(mp(b,x)); niz[b].pb(mp(a,x)); } niz[l+r+1].clear(); niz[0].clear(); int nfus=0; for(auto x:tcvor){ if(niz[x].size()&1){ nfus++; if(x<=l){ niz[x].pb(mp(l+r+1,nfus+m)); niz[l+r+1].pb(mp(x,nfus+m)); }else{ niz[x].pb(mp(0,nfus+m)); niz[0].pb(mp(x,nfus+m)); } } } if(niz[0].size()&1){ nfus++; niz[0].pb(mp(l+r+1,nfus+m)); niz[l+r+1].pb(mp(0,nfus+m)); } for(auto x:tcvor){ //if(x==24)printf(" tst %d %d %d\n",x,dub,niz[x].size()); if(obidjen[niz[x][0].S])continue; ojler(x,0,0,dub); } vector<int> r1,r2; for(auto x:levi) if(x!=0)r1.pb(x); for(auto x:desni) if(x!=0)r2.pb(x); for(auto x:v)obidjen[x]=false; for(int i=m+1;i<=m+nfus;i++)obidjen[i]=false; for(auto x:tcvor)aktivan[x]=false; tcvor.clear(); resi(dub+1,r1); resi(dub+1,r2); } int main() { scanf("%d %d %d", &l, &r, &m); for(int i=1;i<=m;i++){ int t1,t2; scanf("%d %d", &t1, &t2); t2+=l; pocs[t1]++; pocs[t2]++; //printf(" %d %d\n",t1,t2); bboja=max(bboja,max(pocs[t1],pocs[t2])); grane[i]=(mp(t1,t2)); resip.pb(i); } int bbp=1; while((1<<bbp)<bboja)bbp++; maxd=bbp; bboja=1<<bbp; resi(0,resip); printf("%d\n",bboja); for(int i=1;i<=m;i++)printf("%d\n",boje[i]+1); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

teoreticar.cpp: In function 'int main()':
teoreticar.cpp:103:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &l, &r, &m);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
teoreticar.cpp:108:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &t1, &t2);
         ~~~~~^~~~~~~~~~~~~~~~~~~
#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...
#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...