Submission #1008494

#TimeUsernameProblemLanguageResultExecution timeMemory
1008494UnforgettableplAncient Machine (JOI21_ancient_machine)C++17
40 / 100
67 ms10208 KiB
#include "Anna.h" #include <vector> #include <bits/stdc++.h> using namespace std; namespace { int convert(vector<int> arr){ int num = 0; for(int&i:arr){ num*=3; num+=i; } return num; } } void Anna(int N, std::vector<char> S) { for(int i=N;i<100000;i++)S.emplace_back('X'); for(int block = 0;block<100000;block+=5){ vector<int> arr; for(int i=0;i<5;i++){ if(S[i+block]=='X')arr.emplace_back(0); if(S[i+block]=='Y')arr.emplace_back(1); if(S[i+block]=='Z')arr.emplace_back(2); } int res = convert(arr); for(int bit=0;bit<8;bit++)Send(min(1,res&(1<<bit))); } }
#include "Bruno.h" #include <vector> #include <bits/stdc++.h> using namespace std; namespace { vector<int> convert(int x){ vector<int> ans; for(int i=0;i<5;i++){ ans.emplace_back(x%3); x/=3; } reverse(ans.begin(),ans.end()); return ans; } } // namespace void Bruno(int N, int L, std::vector<int> A) { vector<int> arr; for(int i=0;i<160000;i+=8){ int num=0; for(int bit=0;bit<8;bit++){ num |= (A[i+bit]<<bit); } auto curr = convert(num); for(int&i:curr)arr.emplace_back(i); } arr.resize(N); list<pair<int,int>> curr = {{arr[0],0}}; for(int i=1;i<N;i++)if(arr[i]==curr.back().first)Remove(i); else curr.emplace_back(arr[i],i); while(!curr.empty() and curr.front().first!=0){ Remove(curr.front().second); curr.erase(curr.begin()); } while(!curr.empty() and curr.back().first!=2){ Remove(curr.back().second); curr.erase(--curr.end()); } if(curr.empty())return; int last = 1; auto iter = curr.begin(); while(iter!=curr.end()){ if(iter->first==0){ if(last==2 or last==0){ Remove(iter->second); iter = curr.erase(iter); } else { last = 0; iter++; } } else if(iter->first==1){ iter++; last = 1; } else if(iter->first==2){ if(last==0 or last==2){ if(iter->second==curr.back().second){ iter--; Remove(iter->second); iter = curr.erase(iter); iter++; continue; } Remove(iter->second); iter = curr.erase(iter); } else { last = 2; iter++; } } } if(curr.empty())return; if(curr.front().first!=0){ Remove(curr.front().second); return; } iter = curr.begin(); while(iter!=curr.end()){ if(iter->first!=1){iter++;continue;} auto prev = iter++; if(iter->first==2){ Remove(prev->second); assert(iter==curr.erase(prev)); if(iter->second==curr.back().second){ iter++; } else { Remove(iter->second); iter = curr.erase(iter); } } else iter++; } curr.reverse(); iter = ++curr.begin(); while(iter!=curr.end()){ Remove(iter->second); iter = curr.erase(iter); } Remove(curr.front().second); curr.erase(curr.begin()); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...