제출 #425003

#제출 시각아이디문제언어결과실행 시간메모리
425003chirathnirodha버섯 세기 (IOI20_mushrooms)C++17
80.71 / 100
13 ms344 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;
  	vector<int> m;
	int ac=1,bc=0;
	while(cur<n){
		m.clear();
		if(a.size()>=b.size()){
			int tc=0;
			for(int i=0;i<a.size();i++){
				if(cur==n)break;
				m.PB(cur);tc++;
				m.PB(a[i]);
				cur++;
			}
			int x=use_machine(m);
			if(x%2==1)b.PB(m[0]);
			else a.PB(m[0]);
			bc+=(x+1)/2;
			ac+=tc-(x+1)/2;
		}
		else{
			int tc=0;
			for(int i=0;i<b.size();i++){
				if(cur==n)break;
				m.PB(cur);tc++;
				m.PB(b[i]);
				cur++;
			}
			int x=use_machine(m);
			if(x%2==1)a.PB(m[0]);
			else b.PB(m[0]);
			ac+=(x+1)/2;
			bc+=tc-(x+1)/2;
		}
	}
	return ac;
}

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

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