#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(vi v) {
int m = (int)v.size();
int sq = sqrt(m);
int dif = (sq - m / 2) / 8;
sq = m / 2;
if (P == 0.001) {
sq += 0 * dif;
}
else if (P == 0.005256) {
sq += 3 * dif;
}
else if (P == 0.011546) {
sq += 4 * dif;
}
else if (P == 0.028545) {
sq += 4 * dif;
}
else if (P == 0.039856) {
sq += 5 * dif;
}
else if (P == 0.068648) {
sq += 6 * dif;
}
else if (P == 0.104571) {
sq += 7 * dif;
}
else if (P == 0.158765) {
sq += 7 * dif;
}
else {
sq = sqrt(m);
}
int ogt = 0, cur = 0;
vi vec, used(n + 5);
while (1) {
int ind = v[rnd() % m];
if (used[ind]) continue;
++cur, ++ogt;
vec.pub(ind);
used[ind] = 1;
harc[ind] = true;
if (cur == sq || ogt == m) {
if (test_students(harc)) {
for (auto elem : vec) harc[elem] = false;
if (cur == 1) ans[vec[0]] = true;
else {
rec(vec);
}
}
for (auto elem : vec) harc[elem] = false;
vec.clear();
cur = 0;
}
if (ogt == m) break;
}
/*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);
vi vec;
for (int i = 0; i < n; ++i) {
vec.pub(i);
}
rec(vec);
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 |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
344 KB |
Output is correct |
2 |
Correct |
7 ms |
344 KB |
Output is correct |
3 |
Correct |
7 ms |
344 KB |
Output is correct |
4 |
Correct |
8 ms |
344 KB |
Output is correct |
5 |
Correct |
8 ms |
344 KB |
Output is correct |
6 |
Correct |
10 ms |
344 KB |
Output is correct |
7 |
Correct |
10 ms |
344 KB |
Output is correct |
8 |
Correct |
8 ms |
344 KB |
Output is correct |
9 |
Correct |
9 ms |
344 KB |
Output is correct |
10 |
Correct |
5 ms |
344 KB |
Output is correct |
11 |
Correct |
6 ms |
344 KB |
Output is correct |
12 |
Correct |
9 ms |
344 KB |
Output is correct |
13 |
Correct |
7 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 |
8 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
344 KB |
Output is correct (P=0.001, F=15.1, Q=18.9) -> 44.85 points |
2 |
Correct |
178 ms |
344 KB |
Output is correct (P=0.005256, F=51.1, Q=73.6) -> 32.59 points |
3 |
Correct |
340 ms |
344 KB |
Output is correct (P=0.011546, F=94.9, Q=140.3) -> 30.89 points |
4 |
Correct |
654 ms |
600 KB |
Output is correct (P=0.028545, F=191.5, Q=283.3) -> 30.85 points |
5 |
Correct |
847 ms |
344 KB |
Output is correct (P=0.039856, F=246.3, Q=365.6) -> 30.64 points |
6 |
Correct |
1107 ms |
344 KB |
Output is correct (P=0.068648, F=366.2, Q=515.5) -> 34.21 points |
7 |
Correct |
1499 ms |
344 KB |
Output is correct (P=0.104571, F=490.3, Q=717.0) -> 31.58 points |
8 |
Correct |
1925 ms |
596 KB |
Output is correct (P=0.158765, F=639.1, Q=914.4) -> 33.05 points |
9 |
Correct |
1967 ms |
344 KB |
Output is correct (P=0.2, F=731.4, Q=928.8) -> 43.28 points |