Submission #1051627

# Submission time Handle Problem Language Result Execution time Memory
1051627 2024-08-10T08:43:09 Z TahirAliyev Counting Mushrooms (IOI20_mushrooms) C++17
0 / 100
6 ms 344 KB
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define ll long long
#define all(v) v.begin(), v.end()
#define oo 1e9
const int B = 200;

int count_mushrooms(int n){
	int ans = 0, cur = 0, t = 0;
	vector<int> one;
	while(one.size() < B && cur < n){
		int l = cur, r = n - 1;
		while(l < r){
			int mid = (l + r + 1) / 2;
			vector<int> v;
			for(int i = l; i <= mid; i++) v.push_back(i);
			if(!use_machine(v)) l = mid;
			else r = mid - 1;
		}
		if(t) for(int i = cur; i <= l; i++) one.push_back(i);
		else ans += l - cur + 1;
		t ^= 1;
		cur = l + 1;
	}	
	while(cur < n){
		vector<int> v;
		for(int i = 0; i < one.size() && cur < n; i++, cur++){
			v.push_back(one[i]);
			v.push_back(cur);
		}
		ans += (use_machine(v) + 1) / 2;
	}
	return ans;
}

Compilation message

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |   for(int i = 0; i < one.size() && cur < n; i++, cur++){
      |                  ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Partially correct 3 ms 344 KB Output is partially correct
6 Incorrect 6 ms 344 KB Too many total array sizes as queries.
7 Halted 0 ms 0 KB -