제출 #314833

#제출 시각아이디문제언어결과실행 시간메모리
314833kostia244버섯 세기 (IOI20_mushrooms)C++17
0 / 100
1 ms256 KiB
#include "mushrooms.h"
#include<bits/stdc++.h>
using namespace std;
const int C = 7;
int count_mushrooms(int n) {
	vector<int> a{0}, b;
	for(int i = 1; i < min(n, C); i++) {
		(use_machine({0, i}) ? b : a).push_back(i);
	}
	int acc = a.size(), T = 0;
	if(a.size() < b.size()) swap(a, b), T = 1;
	for(int pos = C; pos < n;) {
		vector<int> cur;
		for(int i = 0; i < a.size(); i++) {
			if(i && pos < n) cur.push_back(pos++);
			cur.push_back(a[i]);
		}
		//for(auto i : cur) cout << i << " "; cout << endl;
		int t = use_machine(cur);
		acc += T ? (t/2) : ((cur.size() - a.size()) - t/2);
		cout << acc << endl;
	}
	return acc;
}

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

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