제출 #1296193

#제출 시각아이디문제언어결과실행 시간메모리
1296193eri16버섯 세기 (IOI20_mushrooms)C++20
컴파일 에러
0 ms0 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int n){ vector <int> A; vector <int> B; int ans=1; int cur=150; A.push_back(0); for (int i=1; i<3 && i<n; i++){ vector <int> test; test.push_back(0); test.push_back(i); if (use_machine(test)==0){ A.push_back(i); ans++; } else{ B.push_back(i); } } vector <int> cl; if (A.size()>B.size()){cl=A;} else{cl=B;} for (int i=3; i<150 && i<n; i=i+2){ vector <int> test; test.push_back(i); test.push_back(cl[0]); if (i+1<150 && i+1<n){test.push_back(i+1);test.push_back(cl[1]);} int tmans=use_machine(test); if (cl[0]==0){ if (tmans==0){A.push_back(i);ans++; if (i+1<150 && i+1<n){A.push_back(i+1);ans++;} } if (tmans==1){ B.push_back(i); if (i+1<150 && i+1<n){A.push_back(i+1);ans++;} } if (tmans==2){ A.push_back(i);ans++; if (i+1<150 && i+1<n){A.push_back(i+1);} } if (tmans==3){ B.push_back(i); if (i+1<150 && i+1<n){B.push_back(i+1);} } } else{ if (tmans==3){A.push_back(i);ans++; if (i+1<150 && i+1<n){A.push_back(i+1);ans++;} } if (tmans==2){ B.push_back(i); if (i+1<150 && i+1<n){A.push_back(i+1);ans++;} } if (tmans==1){ A.push_back(i);ans++; if (i+1<150 && i+1<n){A.push_back(i+1);} } if (tmans==0){ B.push_back(i); if (i+1<150 && i+1<n){B.push_back(i+1);} } } } vector <int> c if (A.size()>B.size()){c=A;} else{c=B;} while (cur<n){ vector <int> test; int prv=cur; for (int i=0; i<75 && cur<n; i++){ test.push_back(cur); test.push_back(c[i]); cur++; } int tmans=use_machine(test); if (c[0]==0){ if (tmans%2==0){ans++;} ans=ans+(cur-prv-1)-tmans/2; } else{ if (tmans%2==1){ans++;} ans=ans+tmans/2; } } return ans; }

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:80:5: error: expected initializer before 'if'
   80 |     if (A.size()>B.size()){c=A;}
      |     ^~
mushrooms.cpp:81:5: error: 'else' without a previous 'if'
   81 |     else{c=B;}
      |     ^~~~
mushrooms.cpp:81:10: error: 'c' was not declared in this scope; did you mean 'cl'?
   81 |     else{c=B;}
      |          ^
      |          cl
mushrooms.cpp:91:27: error: 'c' was not declared in this scope
   91 |            test.push_back(c[i]);
      |                           ^
mushrooms.cpp:97:13: error: 'c' was not declared in this scope; did you mean 'cl'?
   97 |         if (c[0]==0){
      |             ^
      |             cl