#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef vector<bool> VB;
int N;
double P;
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';
}
VB find_positive() {
int n = N;
if (P >= 0.2) {
VB answer(n);
rep(i, n) {
VB mask(n);
mask[i] = true;
if (test_students(mask)) answer[i] = true;
}
return answer;
} else {
VB answer(n);
while (true) {
VB query(n);
replr(i, 0, n-1) query[i] = (true && !answer[i]);
if (!test_students(query)) break;
int l = -1, r = n-1;
while (l + 1 < r) {
int m = (l + r) / 2;
VB query(n);
replr(i, 0, m) query[i] = (true && !answer[i]);
bool f = test_students(query);
if (f) r = m;
else l = m;
}
answer[r] = true;
}
return answer;
}
return VB();
}
int main() {
int T;
scanf("%d %lf %d", &N, &P, &T);
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
Main.cpp: In function 'bool test_students(std::vector<bool>)':
Main.cpp:44:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
44 | scanf(" %c", &answer);
| ~~~~~^~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:82:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
82 | scanf("%d %lf %d", &N, &P, &T);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:92:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
92 | scanf(" %c", &verdict);
| ~~~~~^~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
344 KB |
Output is correct |
2 |
Correct |
7 ms |
344 KB |
Output is correct |
3 |
Correct |
5 ms |
344 KB |
Output is correct |
4 |
Correct |
5 ms |
344 KB |
Output is correct |
5 |
Correct |
4 ms |
344 KB |
Output is correct |
6 |
Correct |
5 ms |
344 KB |
Output is correct |
7 |
Correct |
6 ms |
344 KB |
Output is correct |
8 |
Correct |
5 ms |
344 KB |
Output is correct |
9 |
Correct |
5 ms |
344 KB |
Output is correct |
10 |
Correct |
11 ms |
344 KB |
Output is correct |
11 |
Correct |
5 ms |
340 KB |
Output is correct |
12 |
Correct |
7 ms |
344 KB |
Output is correct |
13 |
Correct |
7 ms |
344 KB |
Output is correct |
14 |
Correct |
5 ms |
344 KB |
Output is correct |
15 |
Correct |
5 ms |
344 KB |
Output is correct |
16 |
Correct |
6 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
340 KB |
Output is correct (P=0.001, F=15.1, Q=11.0) -> 90.00 points |
2 |
Correct |
130 ms |
344 KB |
Output is correct (P=0.005256, F=51.1, Q=56.8) -> 62.23 points |
3 |
Correct |
299 ms |
344 KB |
Output is correct (P=0.011546, F=94.9, Q=126.2) -> 38.81 points |
4 |
Correct |
779 ms |
344 KB |
Output is correct (P=0.028545, F=191.5, Q=313.4) -> 25.38 points |
5 |
Correct |
1043 ms |
344 KB |
Output is correct (P=0.039856, F=246.3, Q=440.6) -> 21.66 points |
6 |
Correct |
1821 ms |
344 KB |
Output is correct (P=0.068648, F=366.2, Q=759.0) -> 17.01 points |
7 |
Correct |
2672 ms |
344 KB |
Output is correct (P=0.104571, F=490.3, Q=1153.0) -> 14.05 points |
8 |
Correct |
4464 ms |
344 KB |
Output is correct (P=0.158765, F=639.1, Q=1731.6) -> 11.48 points |
9 |
Correct |
2111 ms |
344 KB |
Output is correct (P=0.2, F=731.4, Q=1000.0) -> 36.45 points |