Submission #1134502

#TimeUsernameProblemLanguageResultExecution timeMemory
1134502NurislamCOVID tests (CEOI24_covid)C++20
10 / 100
521 ms408 KiB
#include <bits/stdc++.h>
using namespace std;
  
//#define int long long
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ff first
#define ss second
#define pb push_back

int n;
double P;
bool tst(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';
}

std::vector<bool> find_positive() {
	vector<bool> ans(n, 0);
	vector<bool> mask(n, 0);
	for(int i = 0; i < n; i += 2){
		mask[i] = 1;
		if(i+1 < n)mask[i+1] = 1;
		if(tst(mask))ans[i] = ans[i+1] = 1;
		mask[i] = 0;
		if(i+1 < n)mask[i+1] = 0;
	}
	for(int i = 0; i < n; i++){
		if(ans[i] == 0)continue;
		mask[i] = 1;
		if(tst(mask) == 0)ans[i] = 0;
		mask[i] = 0;
	}
	
    return ans;
}

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;
}

Compilation message (stderr)

Main.cpp: In function 'bool tst(std::vector<bool>)':
Main.cpp:24:10: 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:50:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |     scanf("%d %lf %d", &n, &P, &T);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:66:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |         scanf(" %c", &verdict);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...