Submission #890731

#TimeUsernameProblemLanguageResultExecution timeMemory
890731null_aweAncient Machine 2 (JOI23_ancient2)C++17
0 / 100
6 ms600 KiB
#include <vector> #include <algorithm> #include "ancient2.h" using namespace std; string Solve(int N) { string ans = ""; while ((int) ans.size() < N) { vector<int> c(2); for (int i = 0; i < (int) ans.size(); ++i) ++c[ans[i] - '0']; int todo = min(c[0], c[1]); if (todo > 99) break; vector<int> a(todo + 3); for (int i = 0; i < todo; ++i) a[i] = i + 1; vector<int> b(todo + 3); for (int i = 0; i < todo; ++i) b[i] = i; a[todo] = a[todo + 1] = todo + 1, a[todo + 2] = todo + 2; b[todo] = b[todo + 2] = todo + 2, b[todo + 1] = todo + 1; if (c[1] < c[0]) swap(a, b); int x = Query(todo + 3, a, b); if (x == a[todo]) ans += "0"; else ans += "1"; } if ((int) ans.size() == N) return ans; while ((int) ans.size() < N) { vector<int> a(102, -1); vector<int> b(102, -1); a[100] = b[100] = 100; a[101] = b[101] = 101; for (int i = 0; i < 98; ++i) a[i] = i + 1, b[i] = i + 1; a[98] = 2, b[98] = 3; int idx = 0; for (int i = 0; i < (int) ans.size(); ++i) { ++idx; if (idx > 98) { if (ans[i] == '0') idx = 7; else idx = 11; } } if (ans.back() == '1') { a[99] = idx; a[idx - 1] = 99; if (idx == 7) a[98] = 99; a[idx] = 100; } else { b[99] = idx; b[idx - 1] = 99; if (idx == 11) b[98] = 99; b[idx] = 100; } for (int i = 0; i < 102; ++i) { if (a[i] < 0) a[i] = 101; if (b[i] < 0) b[i] = 101; } int x = Query(102, a, b); if (x == 100) ans += string(1, ans.back()); else ans += string(1, (char) ('0' + '1' - ans.back())); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...