Submission #1071166

#TimeUsernameProblemLanguageResultExecution timeMemory
1071166thinknoexitAncient Machine (JOI21_ancient_machine)C++17
0 / 100
49 ms9792 KiB
#include "Anna.h" #include<bits/stdc++.h> using namespace std; using ll = long long; namespace { int n; } void Anna(int N, vector<char> S) { n = N; for (int i = 0;i < n;i++) { int v = S[i] - 'X'; Send(!!(v & 1)); Send(!!(v & 2)); } }
#include "Bruno.h" #include<bits/stdc++.h> using namespace std; using ll = long long; namespace { int n; int a[100100], pos[100100]; bool ch[100100]; } // namespace void Bruno(int N, int L, vector<int> A) { n = N; for (int i = 0;i < n;i++) { a[i] = A[2 * i] + 2 * A[2 * i + 1]; } stack<int> st; for (int i = 0;i < n;i++) { pos[i] = -1; if (a[i] == 2) continue; if (a[i] == 0) st.push(i); else { if (st.empty()) Remove(i); else { pos[i] = st.top(); st.pop(); } } } while (!st.empty()) { Remove(st.top()); st.pop(); } for (int i = 0;i < n;i++) { if (pos[i] != -1) { while (!st.empty() && pos[st.top()] > pos[i]) { Remove(st.top()); Remove(pos[st.top()]); st.pop(); } st.push(i); continue; } if (a[i] == 0 || a[i] == 1) continue; if (!st.empty()) { Remove(st.top()); Remove(pos[st.top()]); st.pop(); } Remove(i); } while (!st.empty()) { Remove(st.top()); Remove(pos[st.top()]); st.pop(); } }

Compilation message (stderr)

Bruno.cpp:9:10: warning: '{anonymous}::ch' defined but not used [-Wunused-variable]
    9 |     bool ch[100100];
      |          ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...