Submission #1071033

#TimeUsernameProblemLanguageResultExecution timeMemory
1071033ttamxAncient Machine (JOI21_ancient_machine)C++17
0 / 100
46 ms9192 KiB
#include "Anna.h" #include <bits/stdc++.h> using namespace std; void Anna(int n,vector<char> s){ int seq=0,cnt=0,pw=1; for(int i=0;i<n;i++){ seq+=pw*(s[i]-'X'); cnt++; pw*=3; if(cnt==5){ for(int j=0;j<8;j++){ Send(seq>>j&1); } seq=cnt=0; pw=1; } } if(cnt>0){ for(int j=0;j<8;j++){ Send(seq>>j&1); } } }
#include "Bruno.h" #include <bits/stdc++.h> using namespace std; void Bruno(int n,int m,vector<int> a){ vector<char> s; for(int i=0;i<m;i+=8){ int seq=0; for(int j=0;j<8;j++){ seq|=a[i+j]<<j; } for(int j=0;j<5;j++){ s.emplace_back('X'+seq%3); seq/=3; } } s.resize(n); stack<int> st; for(int i=0;i<n;i++){ if(s[i]=='X'){ if(st.empty()||s[st.top()]=='Y'){ st.emplace(i); }else{ Remove(i); } }else if(s[i]=='Y'){ if(!s.empty()&&s[st.top()]=='X'){ st.emplace(i); }else{ Remove(i); } }else{ while(st.size()>1){ if(st.size()%2){ Remove(st.top()); st.pop(); } Remove(st.top()); st.pop(); } Remove(i); } } while(!st.empty()){ Remove(st.top()); st.pop(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...