Submission #1071380

#TimeUsernameProblemLanguageResultExecution timeMemory
1071380jer033COVID tests (CEOI24_covid)C++17
10 / 100
62 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++) scanf("%i", 0); for (int i=x; i<=y; i++) scanf("%i", 1); for (int i=y+1; i<1000; i++) scanf("%i", 0); cout << '\n'; cout.flush(); 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; } bool range_query(int x, int y) { bool response = ask_query2(x, y); if (response==1) { if (x==y) answer[x] = 1; else { int z = (x+y)/2; range_query(x, z); range_query(z+1, y); } return 1; } return 0; } int main() { int N, T; long double P; cin >> N >> P >> T; if (T==1) { while (T--) { vector<bool> query(N, 0); vector<bool> ans(N, 0); for (int i=0; i<N; i++) { query[i] = 1; ans[i] = ask_query(query); query[i] = 0; } bool L = report(ans); if (L==0) T = 0; } } else { while (T--) { answer_clear(); if (P < 0.01) range_query(0, 999); else if (P < 0.05) { for (int i=1; i<=10; i++) range_query(100*i-100, 100*i-1); } else if (P < 0.11) { for (int i=1; i<=50; i++) range_query(20*i-20, 20*i-1); } else { for (int i=1; i<=100; i++) range_query(10*i-10, 10*i-1); } bool L = report(answer); if (L==0) T = 0; } } }

Compilation message (stderr)

Main.cpp: In function 'bool ask_query2(int, int)':
Main.cpp:30:17: warning: format '%i' expects argument of type 'int*', but argument 2 has type 'int' [-Wformat=]
   30 |         scanf("%i", 0);
      |                ~^   ~
      |                 |   |
      |                 |   int
      |                 int*
Main.cpp:32:17: warning: format '%i' expects argument of type 'int*', but argument 2 has type 'int' [-Wformat=]
   32 |         scanf("%i", 1);
      |                ~^   ~
      |                 |   |
      |                 |   int
      |                 int*
Main.cpp:34:17: warning: format '%i' expects argument of type 'int*', but argument 2 has type 'int' [-Wformat=]
   34 |         scanf("%i", 0);
      |                ~^   ~
      |                 |   |
      |                 |   int
      |                 int*
Main.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         scanf("%i", 0);
      |         ~~~~~^~~~~~~~~
Main.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         scanf("%i", 1);
      |         ~~~~~^~~~~~~~~
Main.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         scanf("%i", 0);
      |         ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...