Submission #427050

#TimeUsernameProblemLanguageResultExecution timeMemory
427050CodePlatinaAncient Machine (JOI21_ancient_machine)C++17
5 / 100
73 ms8660 KiB
#include "Anna.h" #include <bits/stdc++.h> #define pii pair<int, int> #define ff first #define ss second using namespace std; namespace { } void Anna(int N, vector<char> S) { int start = -1, last = -1; for(int i = 0; i < N; ++i) { if(start == -1 && S[i] == 'X') start = i; if(S[i] == 'Z') last = i; } vector<int> R; if(start == -1 || last == -1 || start > last) { Send(0); return; } Send(1); for(int i = 0; i < 16; ++i) Send(start >> i & 1); for(int i = 0; i < 16; ++i) Send(last >> i & 1); for(int i = start + 1; i < last; ++i) { if(S[i] == 'X' && S[i - 1] == 'Y') R.push_back(1); else if(S[i] == 'Y' && S[i + 1] == 'X') R.push_back(1); else R.push_back(0); } for(int i = last + 1; i < N; ++i) R.push_back(0); vector<int> Q{0, 0}; int pt = 0; while(pt < (int)R.size()) { if(R[pt] == 0) Q.push_back(0), ++pt; else Q.push_back(1), pt += 2; } vector<int> T{0, 1}; pt = 0; while(pt < (int)R.size()) { if(R[pt] == 0) { if(pt + 1 < (int)R.size() && R[pt + 1] == 0) T.push_back(0), pt += 2; else T.push_back(1), T.push_back(0), pt += 3; } else T.push_back(1), T.push_back(1), pt += 2; } if(T.size() < Q.size()) swap(T, Q); T = {1, 0}; pt = 0; while(pt < (int)R.size()) { if(R[pt] == 1) { if(pt + 2 < (int)R.size() && R[pt + 2] == 0) T.push_back(0), pt += 3; else T.push_back(1), T.push_back(1), pt += 4; } else T.push_back(1), T.push_back(0), ++pt; } if(T.size() < Q.size()) swap(T, Q); T = {1, 1}; pt = 0; while(pt < (int)R.size()) { if(R[pt] == 1) { if(pt + 2 < (int)R.size() && R[pt + 2] == 0) T.push_back(1), T.push_back(0), pt += 3; else T.push_back(1), T.push_back(1), pt += 4; } else T.push_back(0), ++pt; } if(T.size() < Q.size()) swap(T, Q); for(auto i : Q) Send(i); }
#include "Bruno.h" #include <bits/stdc++.h> using namespace std; namespace { } void Bruno(int N, int L, vector<int> A) { if(A[0] == 0) { for(int i = 0; i < N; ++i) Remove(i); return; } int start = 0, last = 0; for(int i = 0; i < 16; ++i) if(A[i + 1]) start += 1 << i; for(int i = 0; i < 16; ++i) if(A[i + 17]) last += 1 << i; vector<int> B; for(int i = 0; i < start; ++i) B.push_back(0); B.push_back(1); if(A[33] == 0 && A[34] == 0) { for(int i = 35; i < (int)A.size(); ++i) { if(A[i] == 0) B.push_back(0); else B.push_back(1), B.push_back(1); } } else if(A[33] == 0 && A[34] == 1) { for(int i = 35; i < (int)A.size(); i += 2) { if(A[i] == 0) B.push_back(0), B.push_back(0), --i; else if(A[i + 1] == 0) B.push_back(0), B.push_back(1), B.push_back(1); else B.push_back(1), B.push_back(1); } } else if(A[33] == 1 && A[34] == 0) { for(int i = 35; i < (int)A.size(); i += 2) { if(A[i] == 0) B.push_back(1), B.push_back(1), B.push_back(0), --i; else if(A[i + 1] == 0) B.push_back(0); else B.push_back(1), B.push_back(1), B.push_back(1), B.push_back(1); } } else { for(int i = 35; i < (int)A.size(); i += 2) { if(A[i] == 0) B.push_back(0), --i; else if(A[i + 1] == 0) B.push_back(1), B.push_back(1), B.push_back(0); else B.push_back(1), B.push_back(1), B.push_back(1), B.push_back(1); } } B.resize(last); B.push_back(1); for(int i = last + 1; i < N; ++i) B.push_back(0); for(int i = 0; i < N; ++i) if(B[i]) last = i; for(int i = 0; i < N; ++i) if(!B[i]) Remove(i); for(int i = last - 1; i >= 0; --i) if(B[i]) Remove(i); Remove(last); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...