제출 #167688

#제출 시각아이디문제언어결과실행 시간메모리
167688rzbtTeoretičar (COCI18_teoreticar)C++14
0 / 130
12013 ms73540 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[5*MAXN]; int pocs[2*MAXN]; void ojler(int t,int grana,int znak,int 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(); for(auto x:tcvor){ if(niz[x].size()&1){ if(x<=l){ niz[x].pb(mp(l+r+1,0)); niz[l+r+1].pb(mp(x,0)); }else{ niz[x].pb(mp(0,0)); niz[0].pb(mp(x,0)); } } } if(niz[0].size()&1){ niz[0].pb(mp(l+r+1,0)); niz[l+r+1].pb(mp(0,0)); } for(auto x:tcvor){ 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: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]++; 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:95: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:100: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...