Submission #537642

#TimeUsernameProblemLanguageResultExecution timeMemory
537642Jarif_RahmanAncient Machine (JOI21_ancient_machine)C++17
0 / 100
123 ms10732 KiB
#include "Anna.h" #include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; namespace { } void Anna(int n, vector<char> s){ for(int i = 0; i < n; i++){ if(s[i] == 'X') Send(0), Send(0); else if(s[i] == 'Y') Send(0), Send(1); else Send(1); } }
#include "Bruno.h" #include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; namespace { } void Bruno(int n, int m, vector<int> A){ str s = ""; for(int i = 0; i < m; i++){ if(A[i] == 0){ if(A[i+1] == 0) s+="X"; else s+="Y"; i++; } else s+="Z"; } vector<int> lastX(n, -1), firstZ(n, -1); for(int i = 0; i < n; i++){ if(i != 0) lastX[i] = lastX[i-1]; if(s[i] == 'X') lastX[i] = i; } for(int i = n-1; i >= 0; i--){ if(i != n-1) firstZ[i] = firstZ[i+1]; if(s[i] == 'Z') firstZ[i] = i; } vector<array<int, 3>> sth; for(int i = 0; i < n; i++){ if(s[i] != 'Y') continue; if(lastX[i] == -1 || firstZ[i] == -1) continue; sth.pb({lastX[i], i, firstZ[i]}); } sort(sth.begin(), sth.end(), [](array<int, 3> a, array<int, 3> b){ return a[2]-a[0] < b[2]-b[0]; }); set<int> ss; for(int i = 0; i < n; i++) ss.insert(i); for(auto [x, y, z]: sth){ auto itx = ss.find(x); auto ity = ss.find(y); auto itz = ss.find(z); if(itx == ss.end() || ity == ss.end() || itz == ss.end()) continue; itx++; while(itx != itz){ if(itx == ity){ itx++; continue; } Remove(*itx); itx = ss.erase(itx); } Remove(*ity); ss.erase(ity); } while(!ss.empty()){ Remove(*ss.begin()); ss.erase(ss.begin()); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...