답안 #1075110

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1075110 2024-08-25T18:29:11 Z wfe2017 COVID tests (CEOI24_covid) C++14
54.24 / 100
1524 ms 356 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);
			if (mid2 + 1 <= right && query(mid2 + 1, right) == 'P')
				solve(mid2 + 1, right);
		}
		else {
			solve(mid2 + 1, right);
		}
	}
}
 
int main() {
	fastIO();
	cin>>N>>P>>T;
	int len = max(5, min((int)(1.5 / 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;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 6 ms 344 KB Output is correct
3 Correct 7 ms 344 KB Output is correct
4 Correct 7 ms 344 KB Output is correct
5 Correct 8 ms 344 KB Output is correct
6 Correct 8 ms 344 KB Output is correct
7 Correct 6 ms 344 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
9 Correct 10 ms 344 KB Output is correct
10 Correct 4 ms 344 KB Output is correct
11 Correct 5 ms 344 KB Output is correct
12 Correct 5 ms 344 KB Output is correct
13 Correct 6 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 8 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 356 KB Output is correct (P=0.001, F=15.1, Q=15.2) -> 87.68 points
2 Correct 110 ms 344 KB Output is correct (P=0.005256, F=51.1, Q=63.6) -> 45.49 points
3 Correct 211 ms 344 KB Output is correct (P=0.011546, F=94.9, Q=118.8) -> 44.83 points
4 Correct 434 ms 344 KB Output is correct (P=0.028545, F=191.5, Q=235.4) -> 46.95 points
5 Correct 555 ms 344 KB Output is correct (P=0.039856, F=246.3, Q=310.0) -> 44.24 points
6 Correct 808 ms 344 KB Output is correct (P=0.068648, F=366.2, Q=439.6) -> 49.95 points
7 Correct 1143 ms 344 KB Output is correct (P=0.104571, F=490.3, Q=570.7) -> 54.35 points
8 Correct 1402 ms 344 KB Output is correct (P=0.158765, F=639.1, Q=722.1) -> 59.23 points
9 Correct 1524 ms 344 KB Output is correct (P=0.2, F=731.4, Q=817.7) -> 61.14 points