Submission #1025971

# Submission time Handle Problem Language Result Execution time Memory
1025971 2024-07-17T12:02:56 Z model_code COVID tests (CEOI24_covid) C++17
41.44 / 100
1765 ms 600 KB
// Solution which just knary searches.
// I imagine it should receive around 4 pts.
// Author: Ondra Sladký
#include <vector>
#include <queue>
#include <cassert>
#include <string>
using namespace std;


bool test_pupils(vector<int>) ;

vector<int> test(int n, double p) {
	// Do the queries.
	vector<int> ans;
	queue<pair<int, int>> q;
	q.emplace(0, n);
	while(!q.empty()) {
		auto front = q.front();
		int from = front.first;
		int to = front.second;
		q.pop();
		if (to == from) continue;
		vector<int> tested;
		for(int i = from; i < to; ++i) tested.push_back(i);
		int sz = tested.size();
		if (!test_pupils(tested)) continue;
		if (sz == 1) {
			ans.push_back(from);
			continue;
		}
		int k = 4;
		assert(k!=-1);
		int smaller_size = sz / k;
		int higher_size = smaller_size + 1;
		int higher_count = sz % k;
		int smaller_count = k - higher_count;

		for (int i = 0, last = from; i < k; ++i) {
			int dif = higher_size;
			if (i < smaller_count) dif = smaller_size;
			int next = last + dif;
			q.emplace(last, next);
			last = next;
		}
	}
	return ans;
}


int n;
bool test_pupils(vector<int> pupils)
{
	string out(n, '0');
	for(int it : pupils)
		out[it]='1';
	printf("Q %s\n", out.c_str());
	fflush(stdout);
	char in;
	scanf(" %c", &in);
	return in=='P';
}

int main()
{
	double p;
	int t;
	scanf("%d%lf%d", &n, &p, &t);
	for(int ti=0; ti<t; ti++)
	{
		auto positive = test(n, p);
		{
			string out(n, '0');
			for(int it : positive)
				out[it]='1';
			printf("A %s\n", out.c_str());
			fflush(stdout);
			char in;
			scanf(" %c", &in);
			if(in != 'C') return 0;
		}
	}
	return 0;
}

Compilation message

Main.cpp: In function 'bool test_pupils(std::vector<int>)':
Main.cpp:60:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |  scanf(" %c", &in);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:68:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |  scanf("%d%lf%d", &n, &p, &t);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:79:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   79 |    scanf(" %c", &in);
      |    ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 440 KB Output is correct
2 Correct 6 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 6 ms 444 KB Output is correct
5 Correct 6 ms 344 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 6 ms 344 KB Output is correct
8 Correct 4 ms 436 KB Output is correct
9 Correct 5 ms 432 KB Output is correct
10 Correct 5 ms 344 KB Output is correct
11 Correct 6 ms 440 KB Output is correct
12 Correct 6 ms 432 KB Output is correct
13 Correct 6 ms 600 KB Output is correct
14 Correct 7 ms 600 KB Output is correct
15 Correct 7 ms 600 KB Output is correct
16 Correct 7 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 344 KB Output is correct (P=0.001, F=15.1, Q=17.4) -> 55.93 points
2 Correct 131 ms 344 KB Output is correct (P=0.005256, F=51.1, Q=73.4) -> 32.78 points
3 Correct 252 ms 344 KB Output is correct (P=0.011546, F=94.9, Q=139.1) -> 31.44 points
4 Correct 492 ms 600 KB Output is correct (P=0.028545, F=191.5, Q=276.1) -> 32.53 points
5 Correct 600 ms 344 KB Output is correct (P=0.039856, F=246.3, Q=347.9) -> 33.96 points
6 Correct 906 ms 436 KB Output is correct (P=0.068648, F=366.2, Q=500.4) -> 36.50 points
7 Correct 1237 ms 600 KB Output is correct (P=0.104571, F=490.3, Q=646.9) -> 39.52 points
8 Correct 1497 ms 344 KB Output is correct (P=0.158765, F=639.1, Q=813.7) -> 43.00 points
9 Correct 1765 ms 344 KB Output is correct (P=0.2, F=731.4, Q=915.3) -> 44.87 points