제출 #1047460

#제출 시각아이디문제언어결과실행 시간메모리
1047460nightfalCounting Mushrooms (IOI20_mushrooms)C++17
컴파일 에러
0 ms0 KiB
int count2(vector<int> &a, vector<int> &b, int &now, int n, int letter) { vector<int> m; int numA=0, numB=0; for(int i=0; i<a.size() && now < n; i++, now++) { m.push_back(a[i]); m.push_back(now); } int result = use_machine(m); if (result%2) numB++; else numA++; numB += result/2; numA += m.size()/2-1-result/2; if (letter) return numA; else return numB; } void count1(vector<int> &a, vector<int> &b, int num, int n) { int k = min(num,n); for(int i=3; i+1<k; i+=2) { int result = use_machine({a[0],i,a[1],i+1}); if (result%2) b.push_back(i+1); else a.push_back(i+1); if (result/2) b.push_back(i); else a.push_back(i); } if (k%2==0) { if(use_machine({a[0],k-1})) b.push_back(k-1); else a.push_back(k-1); } return; } int count_mushrooms(int n) { vector<int>a, b; a.push_back(0); int numA=0, number1=100; for(int i=1; i<min(3,n); i++) if (use_machine({0,i})) b.push_back(i); else a.push_back(i); if (n<=3) return a.size(); if(a.size()>=b.size()) count1(a,b,number1,n); else count1(b,a,number1,n); if (n<=100) return a.size(); while (number1 < n-1) { if(a.size()>=b.size()) numA += count2(a,b,number1,n,0); else numA += count2(b,a,number1,n,1); } return numA; }

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

mushrooms.cpp:1:12: error: 'vector' was not declared in this scope
    1 | int count2(vector<int> &a, vector<int> &b, int &now, int n, int letter) {
      |            ^~~~~~
mushrooms.cpp:1:19: error: expected primary-expression before 'int'
    1 | int count2(vector<int> &a, vector<int> &b, int &now, int n, int letter) {
      |                   ^~~
mushrooms.cpp:1:28: error: 'vector' was not declared in this scope
    1 | int count2(vector<int> &a, vector<int> &b, int &now, int n, int letter) {
      |                            ^~~~~~
mushrooms.cpp:1:35: error: expected primary-expression before 'int'
    1 | int count2(vector<int> &a, vector<int> &b, int &now, int n, int letter) {
      |                                   ^~~
mushrooms.cpp:1:44: error: expected primary-expression before 'int'
    1 | int count2(vector<int> &a, vector<int> &b, int &now, int n, int letter) {
      |                                            ^~~
mushrooms.cpp:1:54: error: expected primary-expression before 'int'
    1 | int count2(vector<int> &a, vector<int> &b, int &now, int n, int letter) {
      |                                                      ^~~
mushrooms.cpp:1:61: error: expected primary-expression before 'int'
    1 | int count2(vector<int> &a, vector<int> &b, int &now, int n, int letter) {
      |                                                             ^~~
mushrooms.cpp:1:71: error: expression list treated as compound expression in initializer [-fpermissive]
    1 | int count2(vector<int> &a, vector<int> &b, int &now, int n, int letter) {
      |                                                                       ^
mushrooms.cpp:18:6: error: variable or field 'count1' declared void
   18 | void count1(vector<int> &a, vector<int> &b, int num, int n) {
      |      ^~~~~~
mushrooms.cpp:18:13: error: 'vector' was not declared in this scope
   18 | void count1(vector<int> &a, vector<int> &b, int num, int n) {
      |             ^~~~~~
mushrooms.cpp:18:20: error: expected primary-expression before 'int'
   18 | void count1(vector<int> &a, vector<int> &b, int num, int n) {
      |                    ^~~
mushrooms.cpp:18:29: error: 'vector' was not declared in this scope
   18 | void count1(vector<int> &a, vector<int> &b, int num, int n) {
      |                             ^~~~~~
mushrooms.cpp:18:36: error: expected primary-expression before 'int'
   18 | void count1(vector<int> &a, vector<int> &b, int num, int n) {
      |                                    ^~~
mushrooms.cpp:18:45: error: expected primary-expression before 'int'
   18 | void count1(vector<int> &a, vector<int> &b, int num, int n) {
      |                                             ^~~
mushrooms.cpp:18:54: error: expected primary-expression before 'int'
   18 | void count1(vector<int> &a, vector<int> &b, int num, int n) {
      |                                                      ^~~
mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:35:5: error: 'vector' was not declared in this scope
   35 |     vector<int>a, b; a.push_back(0);
      |     ^~~~~~
mushrooms.cpp:35:12: error: expected primary-expression before 'int'
   35 |     vector<int>a, b; a.push_back(0);
      |            ^~~
mushrooms.cpp:35:22: error: 'a' was not declared in this scope
   35 |     vector<int>a, b; a.push_back(0);
      |                      ^
mushrooms.cpp:38:20: error: 'min' was not declared in this scope
   38 |     for(int i=1; i<min(3,n); i++)
      |                    ^~~
mushrooms.cpp:39:13: error: 'use_machine' was not declared in this scope
   39 |         if (use_machine({0,i})) b.push_back(i);
      |             ^~~~~~~~~~~
mushrooms.cpp:39:33: error: 'b' was not declared in this scope
   39 |         if (use_machine({0,i})) b.push_back(i);
      |                                 ^
mushrooms.cpp:43:18: error: 'b' was not declared in this scope
   43 |     if(a.size()>=b.size()) count1(a,b,number1,n);
      |                  ^
mushrooms.cpp:43:28: error: 'count1' was not declared in this scope; did you mean 'count2'?
   43 |     if(a.size()>=b.size()) count1(a,b,number1,n);
      |                            ^~~~~~
      |                            count2
mushrooms.cpp:44:10: error: 'count1' was not declared in this scope; did you mean 'count2'?
   44 |     else count1(b,a,number1,n);
      |          ^~~~~~
      |          count2
mushrooms.cpp:49:22: error: 'b' was not declared in this scope
   49 |         if(a.size()>=b.size()) numA += count2(a,b,number1,n,0);
      |                      ^
mushrooms.cpp:49:62: error: 'count2' cannot be used as a function
   49 |         if(a.size()>=b.size()) numA += count2(a,b,number1,n,0);
      |                                                              ^
mushrooms.cpp:50:44: error: 'count2' cannot be used as a function
   50 |         else numA += count2(b,a,number1,n,1);
      |                                            ^