제출 #424151

#제출 시각아이디문제언어결과실행 시간메모리
424151Supersonic버섯 세기 (IOI20_mushrooms)C++14
25 / 100
38 ms256 KiB
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
int count_mushrooms(int n) {
	vector<int> a={0};
	vector<int> b;int c=1;
	int p=10;
	while(a.size()<p&&b.size()<p&&c<n){
		int k=use_machine({0,c});
		if(k==1)b.push_back(c);else a.push_back(c);
		c++;
	}
	int ca=a.size(),cb=b.size();
	if(c==n)return ca;
	if(a.size()==p){
		//cerr<<a[0]<<':'<<a[1]<<endl;
		while(c<n){
			vector<int> r;
			for(auto i:a){r.push_back(i);r.push_back(c);c++;if(c==n)break;}
			//for(auto i:r)cerr<<i<<' ';cerr<<endl;
			cb+=(use_machine(r)+1)/2;
		}
		return n-cb;
	}
	else {
		while(c<n){
			vector<int> r;
			for(auto i:b){r.push_back(i);r.push_back(c);c++;if(c==n)break;}
			//for(auto i:r)cerr<<i<<' ';cerr<<endl;
			ca+=(use_machine(r)+1)/2;
		}
		return ca;
	}
	exit(1);
}

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:8:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    8 |  while(a.size()<p&&b.size()<p&&c<n){
      |        ~~~~~~~~^~
mushrooms.cpp:8:28: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    8 |  while(a.size()<p&&b.size()<p&&c<n){
      |                    ~~~~~~~~^~
mushrooms.cpp:15:13: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   15 |  if(a.size()==p){
      |     ~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...