제출 #421415

#제출 시각아이디문제언어결과실행 시간메모리
421415Trunkty버섯 세기 (IOI20_mushrooms)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; int count_mushrooms(int n){ int nextm=1; vector<int> a = {0}; vector<int> b = {}; while(a.size()<3 and b.size()<3){ int x = use_machine({0,nextm}); if(x==1){ b.push_back(nextm); } else{ a.push_back(nextm); } nextm++; } while(a.size()<141 and b.size()<141){ if(a.size()>=3){ int x = use_machine({a[0],nextm,a[1],a[2],nextm+1}); if(x==0){ a.push_back(nextm); a.push_back(nextm+1); } else if(x==1){ a.push_back(nextm); b.push_back(nextm+1); } else if(x==2){ b.push_back(nextm); a.push_back(nextm+1); } else{ b.push_back(nextm); b.push_back(nextm+1); } nextm+=2; } else{ int x = use_machine({b[0],nextm,b[1],b[2],nextm+1}); if(x==0){ b.push_back(nextm); b.push_back(nextm+1); } else if(x==1){ b.push_back(nextm); a.push_back(nextm+1); } else if(x==2){ a.push_back(nextm); b.push_back(nextm+1); } else{ a.push_back(nextm); a.push_back(nextm+1); } nextm+=2; } } int cnt=a.size(); while(nextm<n){ if(a.size()>=141){ vector<int> mach = {a[0]}; for(int i=1;i<a.size();i++){ if(nextm==n){ break; } mach.push_back(nextm); mach.push_back(a[i]); nextm++; } int x = use_machine(mach); cnt += ((mach.size()-1)/2)-x/2; } else{ vector<int> mach = {b[0]}; for(int i=1;i<b.size();i++){ if(nextm==n){ break; } mach.push_back(nextm); mach.push_back(b[i]); nextm++; } int x = use_machine(mach); cnt += x/2; } } return cnt; }

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:11:11: error: 'use_machine' was not declared in this scope
   11 |   int x = use_machine({0,nextm});
      |           ^~~~~~~~~~~
mushrooms.cpp:22:12: error: 'use_machine' was not declared in this scope
   22 |    int x = use_machine({a[0],nextm,a[1],a[2],nextm+1});
      |            ^~~~~~~~~~~
mushrooms.cpp:42:12: error: 'use_machine' was not declared in this scope
   42 |    int x = use_machine({b[0],nextm,b[1],b[2],nextm+1});
      |            ^~~~~~~~~~~
mushrooms.cpp:66:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |    for(int i=1;i<a.size();i++){
      |                ~^~~~~~~~~
mushrooms.cpp:74:12: error: 'use_machine' was not declared in this scope
   74 |    int x = use_machine(mach);
      |            ^~~~~~~~~~~
mushrooms.cpp:79:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |    for(int i=1;i<b.size();i++){
      |                ~^~~~~~~~~
mushrooms.cpp:87:12: error: 'use_machine' was not declared in this scope
   87 |    int x = use_machine(mach);
      |            ^~~~~~~~~~~