Submission #1018883

# Submission time Handle Problem Language Result Execution time Memory
1018883 2024-07-10T10:37:41 Z NintsiChkhaidze Counting Mushrooms (IOI20_mushrooms) C++17
0 / 100
1 ms 388 KB
#include "mushrooms.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;

vector <int> v[3];

int count_mushrooms(int n) {
	v[0].pb(0);
	
	int bl = 2*sqrt(n);
	for (int i = 1; i <= min(bl,n - 1); i++){
		vector <int> k; k.pb(0); k.pb(i);
		int res = use_machine(k);
		if (!res) v[0].pb(i);
		else v[1].pb(i);
	}
	
	int ans = (int)v[0].size();
	int id = bl + 1;
	
	while (id < n){
		int m = max(v[0].size(),v[1].size()),d;
		vector <int> vec;
		if (m == v[0].size()){
			vec = v[0]; 
			d = 0;
		}else{
			vec = v[1];
			d = 1;
		}
		
		vector <int> k;
		for (int i = id; i <= id + m - 1; i++){
			k.pb(i);
			k.pb(vec[i - id]);
		}
		int s = use_machine(k);
		int ls = s % 2;
		s -= ls;
		int sum = s/2 + ls;
		
		if (!d) ans += sum;
		else ans += (m - sum);
	}
	
	return ans;
}

Compilation message

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:25:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   if (m == v[0].size()){
      |       ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 388 KB Invalid value 10 in the query array.
4 Halted 0 ms 0 KB -