Submission #1075712

# Submission time Handle Problem Language Result Execution time Memory
1075712 2024-08-26T08:46:21 Z Hugo1729 Counting Mushrooms (IOI20_mushrooms) C++17
0 / 100
0 ms 340 KB
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;

const int S = 200;

int count_mushrooms(int n) {
	vector<int> sus(S,0);

	for(int i=1;i<S;i++){
		sus[i]=sus[i-1];
		if(use_machine({i-1,i}))sus[i]^=1;
	}

	queue<int> q;
	for(int i=S;i<n;i++)q.push(i);

	vector<int> A,B;

	for(int i=0;i<S;i++){
		if(sus[i])B.push_back(i);
		else A.push_back(i);
	}

	int ans=A.size();

	
	while(!q.empty()){
		vector<int> m;

		if(A.size()>=B.size()){
			for(int i=0;i<A.size()&&!q.empty();i++){
				m.push_back(q.front());q.pop();
				m.push_back(A[i]);
			}
			int temp=use_machine(m);
			ans+=(m.size()/2)-((temp+1)/2);
		}else{
			for(int i=0;i<B.size()&&!q.empty();i++){
				m.push_back(q.front());q.pop();
				m.push_back(B[i]);
			}
			int temp=use_machine(m);
			ans+=((temp+1)/2);
		}
	}

	return ans;
}

Compilation message

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:32:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |    for(int i=0;i<A.size()&&!q.empty();i++){
      |                ~^~~~~~~~~
mushrooms.cpp:39:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |    for(int i=0;i<B.size()&&!q.empty();i++){
      |                ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Invalid value 3 in the query array.
2 Halted 0 ms 0 KB -