| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1345998 | MrAndria | COVID tests (CEOI24_covid) | C++20 | 879 ms | 448 KiB |
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int N;
double P;
int p[1005];
std::vector<bool> answer;
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';
}
void rec(int tl,int tr){
vector <bool> dummy(N,0);
for(int i=tl;i<=tr;i++){
dummy[p[i]]=1;
}
bool b=test_students(dummy);
int tm=(tl+tr)/2;
if(b){
if(tl==tr)return;
rec(tl,tm);
rec(tm+1,tr);
}else{
for(int i=tl;i<=tr;i++){
answer[p[i]]=0;
}
}
}
std::vector<bool> find_positive() {
answer.clear();
answer.resize(N);
for(int i=0;i<=N-1;i++){
answer[i]=1;
p[i]=i;
}
for(int i=1;i<=N-1;i++){
swap(p[i],p[rng()%i]);
}
rec(0,N-1);
return answer;
}
int main() {
int T;
scanf("%d %lf %d", &N, &P, &T);
// You may perform any extra initialization here.
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;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
