Submission #1075103

# Submission time Handle Problem Language Result Execution time Memory
1075103 2024-08-25T18:23:00 Z pawned COVID tests (CEOI24_covid) C++17
0 / 100
7 ms 344 KB
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")

#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;

const char nl = '\n';

void fastIO() {
	ios::sync_with_stdio(false);
	cin.tie(0);
}

int N, T;
double P;

char query(vi v) {
	string s(N, '0');
	for (int x : v)
		s[x] = '1';
	cout<<"Q "<<s<<endl;
	cout.flush();
	char c;
	cin>>c;
	return c;
}

char query(int l, int r) {
	string s(N, '0');
	for (int i = l; i <= r; i++) {
		s[i] = '1';
	}
	cout<<"Q "<<s<<endl;
	cout.flush();
	char c;
	cin>>c;
	return c;
}

string ans(N, '0');

void solve(int left, int right) {	// know there's positive on range
	if (left == right) {
		ans[left] = '1';
		return;
	}
	int mid1 = (2 * left + right) / 3;
	int mid2 = (left + 2 * right) / 3;
	if (query(left, mid1) == 'P') {
		solve(left, mid1);
		if (mid1 + 1 <= mid2 && query(mid1 + 1, mid2) == 'P')
			solve(mid1 + 1, mid2);
		if (mid2 + 1 <= right && query(mid2 + 1, right) == 'P')
			solve(mid2 + 1, right);
	}
	else {	// surely has in mid1 to right
		if (mid1 + 1 <= mid2 && query(mid1 + 1, mid2) == 'P')
			solve(mid1 + 1, mid2);
		else {
			if (mid2 + 1 <= right)
				solve(mid2 + 1, right);
		}
	}
}

int main() {
	fastIO();
	cin>>N>>P>>T;
	int len = max(5, min((int)(0.8 / P), N));
	for (int i = 0; i < T; i++) {
		ans = string(N, '0');
		for (int j = 0; j < N; j += len) {
			int lp = j;
			int rp = min(j + len - 1, N - 1);
			if (query(lp, rp) == 'P')
				solve(lp, rp);
		}
//		cout<<"ANSWER: ";
		cout<<"A "<<ans<<endl;
		cout.flush();
		char c;
		cin>>c;
		if (c == 'W')
			break;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 344 KB translate:wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB translate:wrong
2 Halted 0 ms 0 KB -