Submission #1279227

#TimeUsernameProblemLanguageResultExecution timeMemory
1279227loomCOVID tests (CEOI24_covid)C++20
10 / 100
1071 ms404 KiB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define inf (int)5e18
#define nl '\n'

int n;
double P;

bool test_students(std::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> v(n);
   vector<bool> qry(n);
   
   for(int i = 0; i < n; i++){
      qry[i] = true;
      v[i] = test_students(qry);
      qry[i] = false;
   }

   return v;
}

signed main() {
   int T;
   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 'int main()':
Main.cpp:40:12: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   40 |    scanf("%d %lf %d", &n, &P, &T);
      |           ~^          ~~
      |            |          |
      |            int*       long long int*
      |           %lld
Main.cpp:40:19: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
   40 |    scanf("%d %lf %d", &n, &P, &T);
      |                  ~^           ~~
      |                   |           |
      |                   int*        long long int*
      |                  %lld
Main.cpp: In function 'bool test_students(std::vector<bool>)':
Main.cpp:21:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |    scanf(" %c", &answer);
      |    ~~~~~^~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:40:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |    scanf("%d %lf %d", &n, &P, &T);
      |    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:54:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |       scanf(" %c", &verdict);
      |       ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...