제출 #522109

#제출 시각아이디문제언어결과실행 시간메모리
522109new_acc길고양이 (JOI20_stray)C++14
15 / 100
56 ms17796 KiB
#include "Anthony.h" #include<bits/stdc++.h> #define fi first #define se second #define rep(a, b) for(int a = 0; a < int(b); a++) using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; const int NN=2e4+10; int deg[NN],kol[NN],kt[NN]; bool vis[NN]; vi graf[NN],num[NN]; void bfs(){ deque<int> deq; deq.push_back(0),vis[0]=1; while(deq.size()){ int v=deq.front(); deq.pop_front(); for(auto u:graf[v]){ if(!vis[u]){ deg[u]=deg[v]+1,vis[u]=1; deq.push_back(u); } } } } void dfs(int v,int o,int pop=1){ string s="010011"; if(graf[v].size()>2 or graf[v].size()==1){ rep(i,graf[v].size()){ if(graf[v][i]==o) continue; kol[num[v][i]]=(pop+1)%2; } }else{ if(kt[o]==0 and pop==1) kt[v]=0; else kt[v]=(kt[o]+1)%(int)(s.size()); rep(i,graf[v].size()){ if(graf[v][i]==o) continue; kol[num[v][i]]=int(s[kt[v]])-48; } } rep(i,graf[v].size()){ int u=graf[v][i]; if(u==o) continue; dfs(u,v,kol[num[v][i]]); } } vi Mark(int n,int m,int a,int b,vi u,vi v){ rep(i,m) graf[u[i]].push_back(v[i]),graf[v[i]].push_back(u[i]),num[u[i]].push_back(i),num[v[i]].push_back(i); if(b==0){ bfs(); rep(i,n) kol[i]=(i==0?0:(kol[i-1]+1)%3); vi res; rep(i,m) res.push_back(kol[min(deg[u[i]],deg[v[i]])]); return res; } vi wyn; dfs(0,0); rep(i,m) wyn.push_back(kol[i]); return wyn; } /*int main(){ int n,m; cin>>n>>m; vi v,u; rep(i,m){ int a,b; cin>>a>>b; v.push_back(a),u.push_back(b); } vi wyn=Mark(n,m,2,6,v,u); for(auto u:wyn) cout<<u<<"\n"; }*/
#include "Catherine.h" #include<bits/stdc++.h> #define fi first #define se second #define rep(a, b) for(int a = 0; a < (int)(b); a++) using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; const int N=2e4+10; int il; bool strona=0; int ru=0,pocz=-1,pop=0; bool znal; string s; string og="010011"; string d1="01001",d2="10011",d3="00110",d4="01101",d5="11010",d6="10100"; vi akt; void Init(int a,int b){ il=a; } int Move(vi t){ if(il>=3){ bool c[3]; c[0]=c[1]=c[2]=0; rep(i,t.size()) c[i]=(t[i]>0?1:0); if(c[0]>0 and c[1]>0) return 0; if(c[1]>0 and c[2]>0) return 1; if(c[2]>0 and c[0]>0) return 2; if(c[0]) return 0; if(c[1]) return 1; return 2; } if(pocz==-1){ pocz=1; if(t[0] and t[1]){ if(t[0]+t[1]>2){ strona=1; if(t[0]==1){pop=0;return 0;} pop=1; return 1; } akt.push_back(0); s+='1',s+='0'; pop=0; return 0; }else{ if(t[0]==1 or t[1]==1){ strona=1; if(t[0]) {pop=0;return 0;} pop=1; return 1; }else{ if(t[0]){ s+='0'; s+='0'; pop=0; akt.push_back(0); return 0; }else{ s+='1'; s+='1'; pop=1; akt.push_back(1); return 1; } } } }else{ if(strona){ if(t[0] and t[1]){ (pop+=1)%=2; return pop; }else{ if(t[0]){pop=0;return 0;} pop=1; return 1; } }else{ if((int)akt.size()==0){ strona=1; pop=(t[0]>0?0:1); return pop; } if(znal){ int lo=akt.back(); akt.pop_back(); return lo; } if((t[0]>1 and !t[1]) or (t[1]>1 and !t[0]) or (!t[0] and !t[1])) znal=1; if(znal){akt.pop_back();return -1;} if(t[0] and t[1]){ strona=1; (pop+=1)%=2; return pop; } if((int)akt.size()==3){ if(t[0]) s+='0'; if(t[1]) s+='1'; if(s==d1 or s==d2 or s==d3 or s==d4 or s==d5 or s==d6){ znal=1; return -1; }else{ strona=1; if(t[0]) pop=0; else pop=1; return pop; } } if(t[0]) pop=0,s+='0'; else pop=1,s+='1'; akt.push_back(pop); return pop; } } } /*int main(){ vector<int> v; v.push_back(1),v.push_back(1); cout<<Move(v)<<"\n"; v[1]=0; cout<<Move(v)<<"\n"; v[0]=0; cout<<Move(v)<<"\n"; v[0]=1; cout<<Move(v)<<"\n"; v[0]=0,v[1]=1; cout<<Move(v)<<"\n"; v[0]=1,v[1]=0; cout<<Move(v)<<"\n"; }*/
#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...