제출 #417186

#제출 시각아이디문제언어결과실행 시간메모리
417186jamezzzAncient Machine (JOI21_ancient_machine)C++17
0 / 100
84 ms9872 KiB
#include "Anna.h" #include <bits/stdc++.h> using namespace std; namespace{ int X[2],Y[2],Z[2],cntX,cntY,cntZ; void SendX(){ if(X[0]==0)Send(0); else Send(1),Send(X[1]); } void SendY(){ if(Y[0]==0)Send(0); else Send(1),Send(Y[1]); } void SendZ(){ if(Z[0]==0)Send(0); else Send(1),Send(Z[1]); } } void Anna(int N,vector<char> S){ for(int i=0;i<N;++i){ if(S[i]=='X')++cntX; if(S[i]=='Y')++cntY; if(S[i]=='Z')++cntZ; } if(cntX>=cntY&&cntX>=cntZ){ X[0]=0; Y[0]=1;Y[1]=0; Z[0]=1;Z[1]=1; Send(0);Send(0); } else if(cntY>=cntX&&cntY>=cntZ){ X[0]=1;X[1]=0; Y[0]=0; Z[0]=1;Z[1]=1; Send(0);Send(1); } else{ X[0]=1;X[1]=0; Y[0]=1;Y[1]=1; Z[0]=0; Send(1); } for(int i=0;i<N;++i){ if(S[i]=='X')SendX(); if(S[i]=='Y')SendY(); if(S[i]=='Z')SendZ(); } }
#include "Bruno.h" #include <bits/stdc++.h> using namespace std; #define pf printf #define pb push_back namespace{ vector<char> s; char c[2][2]; struct thing{ int x,p,l; }; vector<thing> v; stack<thing> st; void rem(thing t){ for(int i=t.p;i<t.p+t.l;++i){ Remove(i); } } } void Bruno(int N,int L,vector<int> A) { if(A[0]==1){ c[1][0]='X'; c[1][1]='Y'; c[0][0]='Z'; } else if(A[1]==0){ c[0][0]='X'; c[1][0]='Y'; c[1][1]='Z'; } else{ c[1][0]='X'; c[0][0]='Y'; c[1][1]='Z'; } int cur=2; while(cur<L){ if(A[cur]==0)++cur,s.pb(c[0][0]); else if(A[cur+1]==0)cur+=2,s.pb(c[1][0]); else cur+=2,s.pb(c[1][1]); } char pv='L';int p=-1,l=-1; for(int i=0;i<N;++i){ if(s[i]!=pv){ if(pv=='X')v.pb({0,p,l}); if(pv=='Y')v.pb({1,p,l}); if(pv=='Z')v.pb({2,p,l}); pv=s[i],p=i,l=1; } else ++l; } if(pv=='X')v.pb({0,p,l}); if(pv=='Y')v.pb({1,p,l}); if(pv=='Z')v.pb({2,p,l}); int cnt=0; for(thing t:v){ if(t.x==0)st.push(t); else if(t.x==1)st.push(t),++cnt; else{ while(cnt!=0){ thing tp=st.top();st.pop(); rem(tp); if(tp.x==1)--cnt; } rem(t); } } while(!st.empty())rem(st.top()),st.pop(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...