제출 #364934

#제출 시각아이디문제언어결과실행 시간메모리
364934leinad2버섯 세기 (IOI20_mushrooms)C++17
0 / 100
1 ms364 KiB
#include "mushrooms.h" #include<bits/stdc++.h> using namespace std; int count_mushrooms(int n) { if(n<=9) { int ans=1; for(int i=1;i<n;i++) { vector<int>v; v.push_back(0);v.push_back(i); if(use_machine(v)==0)ans++; } return ans; } vector<int>v[2]; v[0].push_back(0); vector<int>qr; qr.push_back(0);qr.push_back(1); v[use_machine(qr)].push_back(1); qr.pop_back();qr.push_back(2); v[use_machine(qr)].push_back(2); qr.pop_back();qr.push_back(3); v[use_machine(qr)].push_back(3); qr.pop_back();qr.push_back(4); v[use_machine(qr)].push_back(4); int y=0, x=0; if(v[0].size()>=3)y=0; else y=1,x=1; int bu=(int)sqrt(n)/2; for(int i=1;i<bu;i++) { vector<int>q; q.push_back(v[x][0]);q.push_back(5*i);q.push_back(v[x][1]);q.push_back(5*i+1);q.push_back(v[x][2]);q.push_back(5*i+2); int ans=use_machine(q); if(ans/2==1) { v[(ans+x)%2].push_back(5*i+2); if(v[1-x].size()<2) { vector<int>qr; qr.push_back(v[x][0]); qr.push_back(5*i+3); qr.push_back(v[x][1]); qr.push_back(5*i+4); int ans=use_machine(qr); v[(ans/2+x)%2].push_back(5*i+3); v[(ans+x)%2].push_back(5*i+4); qr.clear(); qr.push_back(v[x][0]); qr.push_back(5*i); ans=use_machine(qr); v[(ans+x)%2].push_back(5*i); v[(ans+x+1)%2].push_back(5*i+1); } else { vector<int>qr; qr.push_back(v[1-x][0]); qr.push_back(5*i); qr.push_back(v[1-x][1]); qr.push_back(v[x][0]); qr.push_back(5*i+1); qr.push_back(v[x][1]); qr.push_back(5*i+3); qr.push_back(v[x][2]); qr.push_back(5*i+4); int ans=use_machine(qr); ans--; v[(ans/4+x)%2].push_back(5*i); v[(ans/4+x+1)%2].push_back(5*i+1); ans%=4; v[(ans/2+x)%2].push_back(5*i+3); v[(ans+x)%2].push_back(5*i+4); } } else { v[(ans/4+x)%2].push_back(5*i); v[(ans/4+x)%2].push_back(5*i+1); v[(ans+x)%2].push_back(5*i+2); vector<int>qr; qr.push_back(v[x][0]); qr.push_back(5*i+3); qr.push_back(v[x][1]); qr.push_back(5*i+4); int ans=use_machine(qr); v[(ans/2+x)%2].push_back(5*i+3); v[(ans+x)%2].push_back(5*i+4); } } int jump; int ret=v[0].size(); for(int i=5*bu;i<n;i+=jump) { int k; if(v[0].size()>v[1].size()) { k=0; jump=v[0].size(); } else { k=1; jump=v[1].size(); } vector<int>quer; for(int j=i;j<min(i+jump, n);j++) { quer.push_back(v[k][j-i]); quer.push_back(j); } int ans=use_machine(quer); if(k)ret+=(ans/2+ans%2); else ret-=(ans/2+ans%2),ret+=(min(i+jump, n)-i); v[(ans%2)^k].push_back(min(i+jump, n)-1); } return ret; }

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:28:9: warning: variable 'y' set but not used [-Wunused-but-set-variable]
   28 |     int y=0, x=0;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...