제출 #610363

#제출 시각아이디문제언어결과실행 시간메모리
610363Jomnoi버섯 세기 (IOI20_mushrooms)C++17
53.81 / 100
14 ms336 KiB
#include <bits/stdc++.h> #include "mushrooms.h" using namespace std; int result; vector <int> x; vector <int> typeA, typeB; int count_mushrooms(int N) { typeA.push_back(0); int i = 1; while(typeA.size() < 140 and typeB.size() < 140 and i < N) { result = use_machine({0, i}); if(result == 1) { typeB.push_back(i); } else { typeA.push_back(i); } i++; } int numberofA = 0, cnt; while(i < N) { if(typeA.size() > typeB.size()) { x.clear(); cnt = 0; for(int j = 0; j < typeA.size() - 1 and i < N; j++) { x.push_back(typeA[j]); x.push_back(i++); cnt++; } x.push_back(typeA.back()); result = use_machine(x); numberofA += cnt - result / 2; } else { x.clear(); cnt = 0; for(int j = 0; j < typeB.size() - 1 and i < N; j++) { x.push_back(typeB[j]); x.push_back(i++); cnt++; } x.push_back(typeB.back()); result = use_machine(x); numberofA += result / 2; } } return numberofA + typeA.size(); }

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

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