제출 #605305

#제출 시각아이디문제언어결과실행 시간메모리
605305MohamedAliSaidane버섯 세기 (IOI20_mushrooms)C++14
0 / 100
0 ms208 KiB
#include <bits/stdc++.h> #include "mushrooms.h" using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pii> vpi; typedef vector<pll> vpl; #define pb push_back #define popb pop_back #define all(x) (x).begin(),(x).end() int count_mushrooms(int n) { if(n == 2) { vi U; U.pb(0); U.pb(1); if(use_machine(U)) return 2; else return 1; } int ans[n]; ans[0] = 1; vi U; U.pb(0); U.pb(1); if(use_machine(U)) ans[1] = 0; U.popb(); U.pb(2); if(use_machine(U)) ans[2] = 0; int ones = ans[0] + ans[1] + ans[2]; if(ones == 1) { int a = 1; int b = 2; for(int i = 3; i < n - 1; i += 2) { vi V; V.pb(1); V.pb(i); V.pb(2); V.pb(i + 1); int rep = use_machine(V); if(rep == 1) { ans[i] = ans[1]; ans[i + 1] = 1 - ans[1]; } else if(rep == 2) { ans[i] = 1 - ans[1]; ans[i + 1] = ans[1]; } else if(rep == 3) { ans[i] = 1 - ans[1]; ans[i + 1] = 1 - ans[1]; } else { ans[i] = ans[1]; ans[i + 1] = ans[1]; } } if(n%2 == 0) { ans[n - 1] = use_machine({1, n - 1}); } } else { int a = 0; int b = ans[1] ? 1: 2; for(int i = 3; i < n - 1; i += 2) { vi V; V.pb(b); V.pb(i); V.pb(0); V.pb(i + 1); int rep = use_machine(V); if(rep == 1) { ans[i] = ans[0]; ans[i + 1] = 1 - ans[0]; } else if(rep == 2) { ans[i] = 1 - ans[0]; ans[i + 1] = ans[0]; } else if(rep == 3) { ans[i] = 1 - ans[0]; ans[i + 1] = 1 - ans[0]; } else { ans[i] = ans[0]; ans[i + 1] = ans[0]; } } if(n%2 == 0) { ans[n - 1] = 1 - use_machine({0, n - 1}); } } int fin = 0 ; for(int i = 0 ; i < n; i++) fin += ans[i]; return fin; } /* int32_t main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); } */

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:46:17: warning: unused variable 'a' [-Wunused-variable]
   46 |             int a  = 1;
      |                 ^
mushrooms.cpp:47:17: warning: unused variable 'b' [-Wunused-variable]
   47 |             int b = 2;
      |                 ^
mushrooms.cpp:85:17: warning: unused variable 'a' [-Wunused-variable]
   85 |             int a  = 0;
      |                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...