Submission #1068476

# Submission time Handle Problem Language Result Execution time Memory
1068476 2024-08-21T10:05:04 Z vjudge1 COVID tests (CEOI24_covid) C++17
0 / 100
2 ms 356 KB
// 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,prev+mile);
            if (!guess(l,r))
            {
                prev = r+1;
                break;
            }
            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 << mask[i]+'0' << '\n';
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:48:28: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   48 |                 int mid = l+r>>1;
      |                           ~^~
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Protocol violation
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 356 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -