Submission #1044149

# Submission time Handle Problem Language Result Execution time Memory
1044149 2024-08-05T07:37:58 Z Mher777 COVID tests (CEOI24_covid) C++17
0 / 100
5 ms 344 KB
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <array>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <list>
#include <iterator>
#include <numeric>
#include <complex>
#include <utility>
#include <random>
#include <cassert>
#include <fstream>
using namespace std;
mt19937_64 rnd(7069);
typedef int itn;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef float fl;
typedef long double ld;
using vi = vector<int>;
using vll = vector<ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ff first
#define ss second
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mpr make_pair
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define all(x) (x).begin(), (x).end()
#define USACO freopen("feast.in", "r", stdin); freopen("feast.out", "w", stdout);
const int dx[8] = { -1, 0, 1, 0, -1, -1, 1, 1 };
const int dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };
const int MAX = int(1e9 + 5);
const ll MAXL = ll(1e18) + 5ll;
const ll MOD = ll(1000000007);
const ll MOD2 = ll(998244353);
/// You may use:

// The number of students
int N;

// The probability any given student is positive
double P;

// This function performs a test on a subset of samples.
// Its argument is a vector of Booleans of length N,
// where the i-th element is true if the i-th sample should be added to the mix.
// It returns true if (and only if) at least one of the samples in the mix is positive.
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';
    cout << "Q " << mask_str.c_str() << '\n';
    fflush(stdout);

    char answer;
    cin >> answer;
    return answer == 'P';
}

/// You should implement:

// This function will be called once for each test instance.
// It should use test_students to determine which samples are positive.
// It must return a vector of Booleans of length N,
// where the i-th element is true if and only if the i-th sample is positive.

vector<bool> ans, harc;
int n;

void rec(int l, int r) {
    int sq = sqrt(r - l + 1), cur = 0;
    for (int i = l; i <= r; ++i) {
        if (cur == sq) {
            if (test_students(harc)) {
                for (int j = i - sq; j < i; ++j) harc[j] = false;
                if (sq == 1) ans[i - 1] = true;
                else {
                    rec(i - sq, i - 1);
                }
            }
            cur = 0;
        }
        ++cur;
        harc[i] = true;
    }
}

vector<bool> find_positive() {
    n = N;
    ans.assign(n, false);
    harc.assign(n, false);
    rec(0, n - 1);
    return ans;
}

int main() {
    int T;
    cin >> 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';

        cout << "A " << answer_str.c_str() << '\n';
        fflush(stdout);

        char verdict;
        cin >> verdict;
        if (verdict == 'W')
            exit(0);
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB translate:wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 344 KB translate:wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB translate:wrong
2 Halted 0 ms 0 KB -