Submission #1294794

#TimeUsernameProblemLanguageResultExecution timeMemory
1294794Ice_manAncient Machine (JOI21_ancient_machine)C++20
97 / 100
41 ms6452 KiB
#include "Anna.h" #include <vector> #define SZ 45 #define LOG 32 #define PB push_back typedef long long ll; void Anna(int N, std::vector<char> S) { std::vector <int> myv(N); bool lamp = false; for(int i = 0; i < N; i++) if(S[i] == 'X') { lamp = true; myv[i] = 1; for(int j = i + 1; j < N; j++) if(S[j] == 'Z') myv[j] = 1; for(int j = N - 1; j > 0; j--) if(myv[j] == 1 && myv[j - 1] == 1) myv[j - 1] = 0; for(int j = N - 1; j > i + 1; j--) myv[j] = myv[j - 1]; myv[i] = 1; myv[i + 1] = 0; break; } while(myv.size() % SZ != 0) myv.PB(0); std::vector <ll> comb(SZ + 10); comb[0] = 1; comb[1] = 2; for(int i = 2; i <= SZ; i++) comb[i] = comb[i - 1] + comb[i - 2]; for(int i = 0; i < myv.size(); i += SZ) { ll code = 0; for(int j = 0; j < SZ; j++) if(myv[i + j] == true) code += comb[SZ - j - 1]; for(int j = 0; j < LOG; j++) if(code & (1LL << j)) Send(1); else Send(0); } }
#include "Bruno.h" #include <vector> #define SZ 45 #define LOG 32 #define PB push_back typedef long long ll; void Bruno(int N, int L, std::vector<int> A) { std::vector <int> real; std::vector <ll> comb(SZ + 10); comb[0] = 1; comb[1] = 2; for(int i = 2; i <= SZ; i++) comb[i] = comb[i - 1] + comb[i - 2]; for(int i = 0; i < A.size(); i += LOG) { ll code = 0; for(int j = 0; j < LOG; j++) if(A[i + j]) code |= (1LL << j); for(int j = 0; j < SZ; j++) if(code >= comb[SZ - j - 1]) { code -= comb[SZ - j - 1]; real.PB(1); if(j + 1 < SZ) real.PB(0); j++; } else real.PB(0); } for(int i = 0; i < real.size(); i++) if(real[i] == 1) { for(int j = i + 2; j < N; j++) real[j - 1] = real[j]; real[N - 1] = 1; break; } int lamp = 0; int xx = -1; std::vector <bool> used(N , 0); for(int i = 0; i < N; i++) { if(real[i] == 1) { int pp = i - 1; while(real[pp] == false && pp >= 0) { if(used[pp] == true) break; Remove(pp); used[pp] = 1; pp--; } if(lamp == true && used[i] == false) { Remove(i); used[i] = true; } else xx = i; } lamp |= real[i]; } if(xx != -1) { Remove(xx); used[xx] = true; } for(int i = 0; i < N; i++) if(used[i] == false) Remove(i); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...