Submission #1044175

# Submission time Handle Problem Language Result Execution time Memory
1044175 2024-08-05T07:51:04 Z Mher777 COVID tests (CEOI24_covid) C++17
33.08 / 100
1829 ms 596 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;
    if (P <= 0.028545) {
        sq = (r - l + 1) / 2;
    }
    for (int i = l; i <= r; ++i) {
        ++cur;
        harc[i] = true;
        if (cur == sq || i == r) {
            if (test_students(harc)) {
                for (int j = i - cur + 1; j <= i; ++j) harc[j] = false;
                if (cur == 1) ans[i] = true;
                else {
                    rec(i - cur + 1, i);
                }
            }
            for (int j = i - cur + 1; j <= i; ++j) harc[j] = false;
            cur = 0;
        }
    }
}

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 Correct 0 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 344 KB Output is correct
2 Correct 12 ms 344 KB Output is correct
3 Correct 9 ms 344 KB Output is correct
4 Correct 8 ms 344 KB Output is correct
5 Correct 11 ms 344 KB Output is correct
6 Correct 9 ms 344 KB Output is correct
7 Correct 8 ms 344 KB Output is correct
8 Correct 8 ms 344 KB Output is correct
9 Correct 8 ms 344 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 9 ms 344 KB Output is correct
12 Correct 8 ms 344 KB Output is correct
13 Correct 8 ms 344 KB Output is correct
14 Correct 6 ms 344 KB Output is correct
15 Correct 7 ms 344 KB Output is correct
16 Correct 10 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 344 KB Output is correct (P=0.001, F=15.1, Q=19.3) -> 42.60 points
2 Correct 162 ms 344 KB Output is correct (P=0.005256, F=51.1, Q=85.2) -> 24.53 points
3 Correct 305 ms 344 KB Output is correct (P=0.011546, F=94.9, Q=163.7) -> 23.08 points
4 Correct 588 ms 344 KB Output is correct (P=0.028545, F=191.5, Q=323.2) -> 23.99 points
5 Correct 656 ms 344 KB Output is correct (P=0.039856, F=246.3, Q=361.3) -> 31.38 points
6 Correct 995 ms 344 KB Output is correct (P=0.068648, F=366.2, Q=508.3) -> 35.26 points
7 Correct 1349 ms 344 KB Output is correct (P=0.104571, F=490.3, Q=651.6) -> 38.86 points
8 Correct 1628 ms 344 KB Output is correct (P=0.158765, F=639.1, Q=814.1) -> 42.95 points
9 Correct 1829 ms 344 KB Output is correct (P=0.2, F=731.4, Q=927.4) -> 43.44 points