제출 #424221

#제출 시각아이디문제언어결과실행 시간메모리
424221chirathnirodha버섯 세기 (IOI20_mushrooms)C++17
0 / 100
2 ms200 KiB
//Coded by Chirath Nirodha
#include "mushrooms.h"
#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define P push
#define I insert
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
const ll mod=1e9+7;
int count_mushrooms(int n) {
	vector<int> a,b;
	a.push_back(0);
  	int cur=1;
	while(cur<n && cur<100){
		vector<int> m;
		m.PB(0);m.PB(cur);
		int x=use_machine(m);
		if(x==0)a.PB(cur);
		else b.PB(cur);
      	cur++;
	}
	int ans=a.size();
	if(a.size()>=b.size()){
		while(cur<n){
			vector<int> m;
			for(int i=0;i<a.size();i++){
				m.PB(a[i]);
				if(cur==n || i==a.size()-1)break;
				m.PB(cur);
				cur++;
			}
			int x=use_machine(m);
			ans+=a.size()-1-x/2;
		}
	}
	else{
		while(cur<n){
			vector<int> m;
			for(int i=0;i<b.size();i++){
				m.PB(b[i]);
				if(cur==n || i==b.size()-1)break;
				m.PB(cur);
				cur++;
			}
			int x=use_machine(m);
			ans+=x/2;
		}
	}
	return ans;
}

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:31:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |    for(int i=0;i<a.size();i++){
      |                ~^~~~~~~~~
mushrooms.cpp:33:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     if(cur==n || i==a.size()-1)break;
      |                  ~^~~~~~~~~~~~
mushrooms.cpp:44:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |    for(int i=0;i<b.size();i++){
      |                ~^~~~~~~~~
mushrooms.cpp:46:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     if(cur==n || i==b.size()-1)break;
      |                  ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...