답안 #1018891

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1018891 2024-07-10T10:40:15 Z NintsiChkhaidze 버섯 세기 (IOI20_mushrooms) C++17
0 / 100
0 ms 344 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;
		int len = 0;
		for (int i = id; i <= min(n - 1,id + m - 1); i++){
			++len;
			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 += (len - sum);
		
//		if(s == 1) v[d].pb(id);
//		else v[!d].pb(id);
		
		id += m;
	}
	
	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()){
      |       ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 344 KB Answer is not correct.
4 Halted 0 ms 0 KB -