제출 #871311

#제출 시각아이디문제언어결과실행 시간메모리
871311andrei_boaca버섯 세기 (IOI20_mushrooms)C++17
75.59 / 100
5 ms696 KiB
#include "mushrooms.h" #include <bits/stdc++.h> //#include "stub.cpp" using namespace std; int lim=200; int val[20005]; int count_mushrooms(int n) { int nra=1,nrb=0; val[0]=1; vector<int> v={0,1}; int x=use_machine(v); if(x==1) { val[1]=2; nrb++; } else { val[1]=1; nra++; } if(n==2) return nra; v={0,2}; x=use_machine(v); if(x==1) { val[2]=2; nrb++; } else { val[2]=1; nra++; } x=-1; int y=-1; for(int i=1;i<=2;i++) if(val[i]==1) { x=0; y=i; break; } if(x==-1) { x=1; y=2; } int poz=3; while(max(nra,nrb)<lim&&poz<n) { if(poz+1<n) { int ans=use_machine({x,poz,y,poz+1}); if(x==0) { if(ans==0) { nra+=2; val[poz]=1; val[poz+1]=1; } if(ans==1) { nra++; nrb++; val[poz]=1; val[poz+1]=2; } if(ans==2) { nra++; nrb++; val[poz]=2; val[poz+1]=1; } if(ans==3) { nrb+=2; val[poz]=2; val[poz+1]=2; } } else { if(ans==3) { nra+=2; val[poz]=1; val[poz+1]=1; } if(ans==2) { nra++; nrb++; val[poz]=1; val[poz+1]=2; } if(ans==1) { nra++; nrb++; val[poz]=2; val[poz+1]=1; } if(ans==0) { nrb+=2; val[poz]=2; val[poz+1]=2; } } poz+=2; } else { v={0,poz}; int ans=use_machine(v); if(ans==1) { val[poz]=2; nrb++; } else { val[poz]=1; nra++; } return nra; } } vector<int> nums; bool isA=0; if(nra>=lim) { isA=1; for(int i=0;i<n&&nums.size()<lim;i++) if(val[i]==1) nums.push_back(i); } else { isA=0; for(int i=0;i<n&&nums.size()<lim;i++) if(val[i]==2) nums.push_back(i); } while(poz<n) { int cnt=min(n-poz,lim); v.clear(); for(int i=0;i<cnt;i++) { v.push_back(nums[i]); v.push_back(poz+i); } int ans=use_machine(v); int inegal=ans/2+ans%2; int egal=cnt-inegal; if(isA) { nra+=egal; nrb+=inegal; } else { nra+=inegal; nrb+=egal; } poz+=cnt; } return nra; }

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:139:37: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  139 |         for(int i=0;i<n&&nums.size()<lim;i++)
      |                          ~~~~~~~~~~~^~~~
mushrooms.cpp:146:37: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  146 |         for(int i=0;i<n&&nums.size()<lim;i++)
      |                          ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...