제출 #424304

#제출 시각아이디문제언어결과실행 시간메모리
424304ApiramCounting Mushrooms (IOI20_mushrooms)C++14
0 / 100
1 ms200 KiB
#include "mushrooms.h"
#include<bits/stdc++.h>
using namespace std;

int count_mushrooms(int n) {
	vector<int>a,b;
	a.push_back(0);
	int ans=0;
	vector<int>both;
	for (int i =1;i<n;++i){
		both.push_back(i);
		if (both.size()!=max(a.size(),b.size()))continue;
		if (a.size()>b.size()){
			vector<int>cur;
			for (int i =0;i<both.size();++i){
				cur.push_back(both[i]);
				cur.push_back(a[i]);
			}
			int k = use_machine(cur);
			ans+=(k + 1)/2 - 1;
			if (k%2==1){
				a.push_back(cur[0]);
			}
			else b.push_back(cur[0]);
		}
		else {
			vector<int>cur;
			for (int i =0;i<both.size();++i){
				cur.push_back(both[i]);
				cur.push_back(b[i]);
			}
			int k = use_machine(cur);
			ans+=cur.size() - (k + 1)/2 ;
			if (k%2==1){
				b.push_back(cur[0]);
			}
			else a.push_back(cur[0]);
		}
		both.clear();
	}
	if (!both.empty()){
		
		if (a.size()>b.size()){
			vector<int>cur;
			for (int i =0;i<both.size();++i){
				cur.push_back(both[i]);
				cur.push_back(a[i]);
			}
			int k = use_machine(cur);
			ans+=(k + 1)/2 - 1;
			if (k%2==1){
				a.push_back(cur[0]);
			}
			else b.push_back(cur[0]);
		}
		else {
			vector<int>cur;
			for (int i =0;i<both.size();++i){
				cur.push_back(both[i]);
				cur.push_back(b[i]);
			}
			int k = use_machine(cur);
			ans+=cur.size() - (k + 1)/2 ;
			if (k%2==1){
				b.push_back(cur[0]);
			}
			else a.push_back(cur[0]);
		}
	}
	return ans + a.size();
}

컴파일 시 표준 에러 (stderr) 메시지

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:15:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |    for (int i =0;i<both.size();++i){
      |                  ~^~~~~~~~~~~~
mushrooms.cpp:28:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |    for (int i =0;i<both.size();++i){
      |                  ~^~~~~~~~~~~~
mushrooms.cpp:45:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |    for (int i =0;i<both.size();++i){
      |                  ~^~~~~~~~~~~~
mushrooms.cpp:58:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |    for (int i =0;i<both.size();++i){
      |                  ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...