Submission #1044259

#TimeUsernameProblemLanguageResultExecution timeMemory
1044259alex_2008COVID tests (CEOI24_covid)C++14
22.55 / 100
1789 ms344 KiB
#include <iostream> #include <cmath> #include <algorithm> #include <vector> #include <map> #include <queue> #include <stack> typedef long long ll; using namespace std; const int N = 2e5 + 10; int n, t; long double p; bool ch(int l, int r) { if (l > r) return false; string s = string(n, '0'); for (int i = l - 1; i < r; i++) { s[i] = '1'; } cout << "Q " << s << endl; char x; cin >> x; if (x == 'P') return true; return false; } int main() { cin >> n >> p >> t; if (t == 1) { string ans = string(n, '0'); for (int i = 1; i <= n; i++) { cout << "Q "; string s = string(n, '0'); s[i - 1] = '1'; cout << s << endl; char x; cin >> x; if (x == 'P') ans[i - 1] = '1'; } cout << "A " << ans << endl; char x; cin >> x; return 0; } int block; if (p <= 0.01) block = 1000; if (p <= 0.02) block = 255; if (p <= 0.03) block = 255; if (p <= 0.04) block = 127; if (p <= 0.07) block = 127; if (p <= 0.11) block = 63; if (p <= 0.16) block = 63; if (p <= 0.21) block = 31; while (t--) { string answ = string(n, '0'); for (int i = 1; i <= n; i += block) { int mx_r = min(n, i + block - 1); int last = i - 1; while (1) { if (!ch(last + 1, mx_r)) { break; } int l = last + 1, r = mx_r - 1, ans = last; while (l <= r) { int mid = (l + r) / 2; if (!ch(last + 1, mid)) { ans = mid; l = mid + 1; } else r = mid - 1; } answ[ans] = '1'; last = ans + 1; } } cout << "A " << answ << endl; char x; cin >> x; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...