Submission #1316648

#TimeUsernameProblemLanguageResultExecution timeMemory
1316648tvgkAncient Machine (JOI21_ancient_machine)C++20
70 / 100
42 ms6580 KiB
#include<bits/stdc++.h> #include "Anna.h" #include <vector> using namespace std; #define task "a" #define se second #define fi first #define ll long long #define ii pair<ll, ll> const long mxN = 2e5 + 7, inf = 1e9 + 7; void Anna(int n, std::vector<char> s) { bool stt = 0; for (char i : s) { if (!stt) { if (i == 'X') { stt = 1; Send(1); } else Send(0); } else Send(i == 'Z'); } }
#include "Bruno.h" #include <vector> #include<bits/stdc++.h> using namespace std; #define task "a" #define se second #define fi first #define ll long long #define ii pair<ll, ll> const long mxN = 2e5 + 7; void Bruno(int n, int l, std::vector<int> a) { string s; int stt = 0; for (int i = 0; i < n; i++) { if (a[i]) { if (!stt) s += 'X'; else s += 'Z'; stt = 1; } else s += 'Y'; } stack<int> stk; stt = -1; for (int i = 0; i < n; i++) { if (s[i] == 'X' && stt == -1) stt = i; if (stt == -1) { Remove(i); continue; } if (s[i] == 'Z') { while (stk.size() > 1) { Remove(stk.top()); stk.pop(); } Remove(i); } else stk.push(i); } while (stk.size()) { Remove(stk.top()); stk.pop(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...