Submission #950908

#TimeUsernameProblemLanguageResultExecution timeMemory
950908qwe1rt1yuiop1Toxic Gene (NOI23_toxic)C++17
2.78 / 100
9 ms604 KiB
#include "toxic.h" using namespace std; #include <bits/stdc++.h> vector<int> v; string ans; void ac(int x, char c) { assert(ans[x] == '0'); answer_type(x, c); ans[x] = c; } int qry() { return query_sample(v); } int qry1(int l, int r) { v.clear(); for (int i = l; i <= r; ++i) v.emplace_back(i); return qry(); } void determine_type(int n) { ans.assign(n + 1, '0'); vector<int> t; t.emplace_back(0); while (1) { int l = t.back() + 1, r = n; if (qry1(l, r) == r - l + 1) break; while (l < r) { int mid = (l + r) >> 1; if (qry1(l, mid) == mid - l + 1) l = mid + 1; else r = mid; } t.emplace_back(l); ac(l, 'T'); } for (int i = 1; i <= n; ++i) if (ans[i] == '0') { v.clear(); v.emplace_back(t.back()); v.emplace_back(i); if (qry() == 1) ac(i, 'S'); else ac(i, 'R'); } }
#Verdict Execution timeMemoryGrader output
Fetching results...