제출 #427504

#제출 시각아이디문제언어결과실행 시간메모리
427504Osama_AlkhodairyAncient Machine (JOI21_ancient_machine)C++17
69 / 100
88 ms9072 KiB
#include <bits/stdc++.h> #include "Anna.h" using namespace std; void Anna(int N, std::vector<char> S) { int firstX = N; for(int i = 0 ; i < N ; i++){ if(S[i] == 'X'){ firstX = i; break; } } int lastZ = N; for(int i = N - 1 ; i >= 0 ; i--){ if(S[i] == 'Z'){ lastZ = i; break; } } for(int i = 16 ; i >= 0 ; i--){ Send((firstX >> i) & 1); } for(int i = 16 ; i >= 0 ; i--){ Send((lastZ >> i) & 1); } vector <int> f(N); for(int i = firstX + 1 ; i < lastZ ; i++){ if(S[i] == 'Y' && S[i - 1] != 'Y'){ f[i] = 1; if(S[i - 1] == 'Z') f[i - 1] = 1; } } for(int i = 0 ; i < N ; i++){ Send(f[i]); } }
#include <bits/stdc++.h> #include "Bruno.h" using namespace std; void Bruno(int N, int L, std::vector<int> A) { reverse(A.begin(), A.end()); auto get = [&](){ assert(A.size()); int x = A.back(); A.pop_back(); return x; }; int firstX = 0; for(int i = 0 ; i < 17 ; i++){ firstX = 2 * firstX + get(); } int lastZ = 0; for(int i = 0 ; i < 17 ; i++){ lastZ = 2 * lastZ + get(); } if(firstX == N || lastZ == N){ for(int i = 0 ; i < N ; i++){ Remove(i); } return; } string S(N, ';'); S[firstX] = 'X'; S[lastZ] = 'Z'; vector <int> f(N); for(int i = 0 ; i < N ; i++){ f[i] = get(); } for(int i = lastZ - 1 ; i > firstX ; i--){ if(f[i]){ S[i] = 'Y'; if(f[i - 1]) S[i - 1] = 'Z'; else S[i - 1] = 'X'; i--; } } for(int i = 0 ; i < N ; i++){ if(S[i] == ';') Remove(i); } vector <int> g; for(int i = 0 ; i < N ; i++){ if(S[i] == ';') continue; if(S[i] == 'X'){ if(g.size() && S[g.back()] == 'X'){ Remove(i); } else g.push_back(i); } else if(S[i] == 'Y'){ g.push_back(i); } else{ if(g.size() && S[g.back()] == 'X'){ Remove(i); } else{ while(g.size() > 1){ Remove(g.back()); g.pop_back(); } Remove(i); } } } for(auto &i : g) Remove(i); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...