제출 #1137684

#제출 시각아이디문제언어결과실행 시간메모리
1137684KaleemRazaSyedCOVID tests (CEOI24_covid)C++20
31.11 / 100
6200 ms1114112 KiB
#include<bits/stdc++.h> using namespace std; mt19937 rnd(std::chrono::system_clock::now().time_since_epoch().count()); int n; double p; map<double, int> base; bool ask(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<int> fig(vector<int> a) { if(a.empty()) return a; vector<bool> mask(n, false); vector<int> sol; for(int i : a) mask[i] = true; if(!ask(mask)) return sol; if(a.size() == 1) return a; vector<int> b; int bp = 1; if(base.find(p) != base.end()) bp = base[p]; int c = (a.size() + bp - 1) / bp; for(int i = 0; i < a.size(); i++) { b.push_back(a[i]); if(b.size() == c || i + 1 == a.size()) { vector<int> solp = fig(b); for(int x : solp) sol.push_back(x); b.clear(); } } return sol; } vector<bool> solve() { vector<int> idx(n); iota(idx.begin(), idx.end(), 0); for(int i = 0; i < n; i ++) { int j = rnd() % (i + 1); swap(idx[i], idx[j]); } vector<bool> v(n, false); vector<int> sol = fig(idx); for(int i : sol) v[i] = true; return v; } int main() { int T; scanf("%d %lf %d", &n, &p, &T); base[0.001] = 2; base[0.005256] = 3; base[0.011546] = 4; base[0.028545] = 4; base[0.039856] = 4; base[0.068648] = 4; base[0.104571] = 4; base[0.158765] = 4; base[0.2] = 5; for (int i = 0; i < T; i++) { vector<bool> answer = solve(); assert(answer.size() == (size_t)n); 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; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'bool ask(std::vector<bool>)':
Main.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   scanf(" %c", &answer);
      |   ~~~~~^~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:83:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   83 |   scanf("%d %lf %d", &n, &p, &T);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:106:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  106 |     scanf(" %c", &verdict);
      |     ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...