// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
int n,t;
bool guess(int l,int r){
cout << "Q ";
for (int i = 0; i < n; i++)
{
if (i >= l && i <= r)
cout << '1';
else
cout << '0';
}
cout << endl;
char la;
cin >> la;
if (la == 'P')
return 1;
else
return 0;
}
void calc(vector<bool>& mask, int l, int r)
{
if (l==r)
{
mask[l] = 1;
return;
}
int mid = l+r>>1;
if (guess(l,mid))
calc(mask,l,mid);
if (guess(mid+1,r))
calc(mask,mid+1,r);
}
void linear(vector<bool>&mask,int mile)
{
int prev = 0;
while(prev<n)
{
if (guess(prev,min(n-1,prev+mile)))
for (int i = prev;i <= min(n-1,prev+mile); i++)
if (guess(i,i))
mask[i] = 1;
prev = min(n,prev+mile+1);
}
}
signed main() {
double p;
ios::sync_with_stdio(0);
cin >> n >> p >> t;
double tte = 1/p;
int mile = (int)tte;
while(t--)
{
int prev = 0;
vector<bool> mask(n,0);
if (mile < 13)
{
linear(mask,mile);
}
else if (mile < 100)
{
calc(mask,0,n-1);
}
else
while(prev < n)
{
int l = prev, r = min(n-1,prev+max(4ll,mile));
if (!guess(l,r))
{
prev = r+1;
continue;
}
while (r-l>1)
{
int mid = l+r>>1;
if (guess(prev,mid))
r = mid;
else
l = mid;
}
if (guess(l,l))
{
mask[l] = 1;
prev = r;
}
else
{
mask[r] = 1;
prev = r+1;
}
}
cout << "A ";
for (int i = 0; i < n; i++)
cout << (char)(mask[i]+'0');
cout << endl;
char c;
cin >> c;
if (c=='C')
continue;
else
break;
}
}
Compilation message
Main.cpp: In function 'void calc(std::vector<bool>&, long long int, long long int)':
Main.cpp:33:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
33 | int mid = l+r>>1;
| ~^~
Main.cpp: In function 'int main()':
Main.cpp:84:28: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
84 | int mid = l+r>>1;
| ~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
344 KB |
Output is correct |
2 |
Correct |
27 ms |
344 KB |
Output is correct |
3 |
Correct |
32 ms |
344 KB |
Output is correct |
4 |
Correct |
29 ms |
344 KB |
Output is correct |
5 |
Correct |
36 ms |
344 KB |
Output is correct |
6 |
Correct |
34 ms |
340 KB |
Output is correct |
7 |
Correct |
31 ms |
344 KB |
Output is correct |
8 |
Correct |
22 ms |
344 KB |
Output is correct |
9 |
Correct |
25 ms |
340 KB |
Output is correct |
10 |
Correct |
22 ms |
344 KB |
Output is correct |
11 |
Correct |
23 ms |
344 KB |
Output is correct |
12 |
Correct |
30 ms |
344 KB |
Output is correct |
13 |
Correct |
30 ms |
344 KB |
Output is correct |
14 |
Correct |
28 ms |
344 KB |
Output is correct |
15 |
Correct |
22 ms |
344 KB |
Output is correct |
16 |
Correct |
32 ms |
344 KB |
Output is correct |
17 |
Correct |
19 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
78 ms |
344 KB |
Output is correct (P=0.001, F=15.1, Q=11.6) -> 90.00 points |
2 |
Correct |
375 ms |
344 KB |
Output is correct (P=0.005256, F=51.1, Q=52.3) -> 82.27 points |
3 |
Correct |
1042 ms |
344 KB |
Output is correct (P=0.011546, F=94.9, Q=149.0) -> 27.44 points |
4 |
Correct |
2061 ms |
344 KB |
Output is correct (P=0.028545, F=191.5, Q=302.5) -> 27.12 points |
5 |
Correct |
2731 ms |
348 KB |
Output is correct (P=0.039856, F=246.3, Q=387.5) -> 27.33 points |
6 |
Correct |
3859 ms |
344 KB |
Output is correct (P=0.068648, F=366.2, Q=568.4) -> 28.05 points |
7 |
Correct |
5297 ms |
344 KB |
Output is correct (P=0.104571, F=490.3, Q=767.3) -> 27.61 points |
8 |
Correct |
5776 ms |
340 KB |
Output is correct (P=0.158765, F=639.1, Q=842.6) -> 39.58 points |
9 |
Correct |
6049 ms |
344 KB |
Output is correct (P=0.2, F=731.4, Q=903.5) -> 46.36 points |