// 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;
}
signed main() {
double p;
cin >> n >> p >> t;
double tte = 1/p;
int mile = (int)tte;
while(t--)
{
int prev = 0;
vector<bool> mask(n,0);
while(prev < n)
{
int l = prev, r = min(n-1,prev+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 'int main()':
Main.cpp:48:28: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
48 | int mid = l+r>>1;
| ~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
7003 ms |
344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
125 ms |
344 KB |
Output is correct (P=0.001, F=15.1, Q=11.6) -> 90.00 points |
2 |
Correct |
480 ms |
344 KB |
Output is correct (P=0.005256, F=51.1, Q=52.3) -> 82.27 points |
3 |
Correct |
889 ms |
344 KB |
Output is correct (P=0.011546, F=94.9, Q=103.5) -> 66.06 points |
4 |
Correct |
1767 ms |
344 KB |
Output is correct (P=0.028545, F=191.5, Q=218.3) -> 57.70 points |
5 |
Execution timed out |
7016 ms |
344 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |