Submission #1073426

#TimeUsernameProblemLanguageResultExecution timeMemory
1073426jer033COVID tests (CEOI24_covid)C++17
82.74 / 100
5088 ms344 KiB
#include <bits/stdc++.h> using namespace std; vector<bool> answer(1000, 0); void answer_clear() { for (int i=0; i<1000; i++) answer[i] = 0; } bool ask_query(vector<bool> a) { cout << "Q "; for (int i=0; i<1000; i++) cout << a[i]; cout << '\n'; cout.flush(); char x; cin >> x; if (x=='P') return 1; return 0; } bool ask_query2(int x, int y) { cout << "Q "; for (int i=0; i<x; i++) cout << '0'; for (int i=x; i<=y; i++) cout << '1'; for (int i=y+1; i<1000; i++) cout << '0'; cout << endl; char k; cin >> k; if (k=='P') return 1; return 0; } bool report(vector<bool> a) { cout << "A "; for (int i=0; i<1000; i++) cout << a[i]; cout << '\n'; cout.flush(); char x; cin >> x; if (x=='C') return 1; return 0; } long double prob; int range_first(int x, int y, bool known) { if (x>y) return -5; bool response; if (known) response = 1; else response = ask_query2(x, y); if (response == 0) return -5; if (x==y) { answer[x] = 1; return x; } int z = (x+y)/2; int k = range_first(x, z, 0); if (k!=-5) return k; return range_first(z+1, y, 1); } void range_query(int x, int y) { int currx = x; while (currx!=-4) { currx = range_first(currx, y, 0); currx++; } } void work(int m) { int curr = 0; bool go_on = 1; while (go_on) { range_query(curr, min(curr+m-1, 999)); if ((curr+m-1)>=999) go_on = 0; curr+=m; } } int main() { std::ios::sync_with_stdio(false); int N, T; long double P; cin >> N >> P >> T; if (T==1) { while (T--) { work(1); bool L = report(answer); if (L==0) T = 0; } } else { prob = P; while (T--) { answer_clear(); if (P < 0.005) work(1000); else if (P < 0.01) work(200); else if (P < 0.02) work(125); else if (P < 0.03) work(40); else if (P < 0.05) work(34); else if (P < 0.10) work(11); else if (P < 0.15) work(6); else if (P < 0.19) work(4); else work(3); bool L = report(answer); if (L==0) T = 0; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...