제출 #607564

#제출 시각아이디문제언어결과실행 시간메모리
607564keta_tsimakuridzeCounting Mushrooms (IOI20_mushrooms)C++14
25 / 100
136 ms292 KiB
#include "mushrooms.h"
#include<bits/stdc++.h>
using namespace std;
int count_mushrooms(int n) {
	vector<int> A, B, x;
	int ans = 1;
	for(int i = 1; i < n; i += 2) {
        if(i + 1 < n)
        ans += (2 - use_machine({i, 0, i + 1}));
        else ans += !use_machine({0, i});
	}
	return ans;
	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:19:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |             for(int i = 0; i < A.size(); i++) {
      |                            ~~^~~~~~~~~~
mushrooms.cpp:33:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |             for(int i = 0; i < B.size(); i++) {
      |                            ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...