Submission #1134364

#TimeUsernameProblemLanguageResultExecution timeMemory
1134364ReLiceCOVID tests (CEOI24_covid)C++20
10 / 100
4 ms436 KiB
#include <bits/stdc++.h> #define ll int #define ld double #define pb push_back #define pf push_front #define ins insert #define fr first #define sc second #define endl "\n" #define ar array #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() using namespace std; void start(){ios_base::sync_with_stdio(NULL);cin.tie(nullptr);cout.tie(nullptr);} ll N; double P; ll t; bool check(vector<bool> mask) { assert(mask.size() == (size_t)N); std::string mask_str(N, ' '); for (int i = 0; i < N; i++) mask_str[i] = mask[i] ? '1' : '0'; printf("Q %s\n", mask_str.c_str()); fflush(stdout); char answer; scanf(" %c", &answer); return answer == 'P'; } vector<bool> find_positive() { vector<bool> ans(N, false), cur(N); ll i; ll n = N; if(t != 1){ for(i=0;i<n;i++) cur[i] = 1; if(!check(cur)) return ans; for(i=0;i<n;i++) cur[i] = 0; ll L = 0; ll R = n - 1; cur[R] = 1; ans[R] = check(cur); cur[R] = 0; if(!ans[R]){ ll l = 0, r = R; while(l + 1 < r){ ll m = (l + r) / 2; for(i=m;i<=R;i++) cur[i] = 1; if(check(cur)) l = m; else r = m; for(i=m;i<=R;i++) cur[i] = 0; } R = l; } while(L < R){ while(L < R){ cur[L] = 1; ans[L] = check(cur); cur[L] = 0; if(ans[L] == 0) break; L++; } ll l = L, r = R; while(l + 1 < r){ ll m = (l + r) / 2; for(i=0;i<=m;i++) cur[i] = 1; if(check(cur)) r = m; else l = m; } ans[r] = 1; L = r + 1; } } else { for(i=0;i<n;i++){ cur[i] = 1; ans[i] = check(cur); cur[i] = 0; } } return ans; } int main() { start(); scanf("%d %lf %d", &N, &P, &t); for (int i = 0; i < t; i++) { std::vector<bool> answer = find_positive(); assert(answer.size() == (size_t)N); std::string answer_str(N, ' '); for (int j = 0; j < N; j++) answer_str[j] = answer[j] ? '1' : '0'; printf("A %s\n", answer_str.c_str()); fflush(stdout); char verdict; scanf(" %c", &verdict); if (verdict == 'W') exit(0); } return 0; } /* */

Compilation message (stderr)

Main.cpp: In function 'bool check(std::vector<bool>)':
Main.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     scanf(" %c", &answer);
      |     ~~~~~^~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:108:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  108 |     scanf("%d %lf %d", &N, &P, &t);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:122:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  122 |         scanf(" %c", &verdict);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...