Submission #1076394

#TimeUsernameProblemLanguageResultExecution timeMemory
1076394mindiyakCounting Mushrooms (IOI20_mushrooms)C++14
10 / 100
145 ms384 KiB
#include "mushrooms.h"
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int count_mushrooms(int n) {
	//A = 0 | B = 1
	vector<int> type(n,-1);
	type[0] = 0;

	int pos = -1;
	for(int i = 1;i<n;i++){
		if(use_machine({0,i}) == 0){
			// pos = i;
			type[i] = 0;
			// break;
		}else{
			type[i] = 1;
		}
	}

	// cerr << pos << endl;

	// while(true){
	// 	int a=0,b=0;
	// 	while(a < n && type[a] != -1)a++;
	// 	if(a >= n)break; 
	// 	b = a+1;
	// 	while(b < n && type[b] != -1)b++;
	// 	// cerr << a << " " << b << " " << pos << endl;

	// 	if(b >= n){
	// 		if(use_machine({0,a}) == 0){
	// 			type[a] = 0;
	// 		}else{
	// 			type[a] = 1;
	// 		}
	// 	}else{
	// 		int val = use_machine({a,0,pos,b});
	// 		if(val%2 == 1){
	// 			type[a] = 1;
	// 		}else{
	// 			type[a] = 0;
	// 		}
	// 		if(val > 1){
	// 			type[b] = 1;
	// 		}else{
	// 			type[b] = 0;
	// 		}
	// 	}
	// }

	int ans = 0;
	// for(int i=0;i<n;i++)cerr << type[i] << " ";
	// cerr << endl;
	for(int i=0;i<n;i++)ans += (type[i]+1)%2;
	return ans;
}

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:13:6: warning: unused variable 'pos' [-Wunused-variable]
   13 |  int pos = -1;
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...