제출 #607558

#제출 시각아이디문제언어결과실행 시간메모리
607558keta_tsimakuridzeCounting Mushrooms (IOI20_mushrooms)C++17
0 / 100
0 ms208 KiB
#include "mushrooms.h"
#include<bits/stdc++.h>
using namespace std;
int count_mushrooms(int n) {
	vector<int> A, B, x;
	for(int i = 1; i < n; i++) {
        x.push_back(i);
	}
	A.push_back(0);
	int cntA = 1;
	while(x.size()) {
        if(A.size() >= B.size()) {
            vector<int> v;
            int nn = 0;
            for(int i = 0; i < A.size(); i++) {
                v.push_back(A[i]);
                v.push_back(x.back());
                x.pop_back(); ++nn;
                if(!x.size()) break;
            }
            if(x.size()) v.push_back(x.back()), x.pop_back(), ++nn;
            int x = use_machine(v);
            cntA += nn - (x / 2 + x % 2);
            if(x % 2) B.push_back(v.back());
            else A.push_back(v.back());
        } else {
            vector<int> v;
            int nn = 0;
            for(int i = 0; i < B.size(); i++) {
                v.push_back(B[i]);
                v.push_back(x.back());
                x.pop_back(); ++nn;
                if(!x.size()) break;
            }
            if(x.size()) v.push_back(x.back()), x.pop_back();
            int x = use_machine(v);
            cntA += (x / 2 + x % 2);
            if(x % 2 == 0) B.push_back(v.back());
            else A.push_back(v.back());
        }
	}
	return cntA;
}

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

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