제출 #800690

#제출 시각아이디문제언어결과실행 시간메모리
800690FEDIKUS버섯 세기 (IOI20_mushrooms)C++17
0 / 100
1 ms208 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; const int maxn=20010; int count_mushrooms(int n) { vector<int> aovi={0}; vector<int> bovi; int ret=1; int w=100; for(int i=1;i<n;i++){ if(aovi.size()>=w && aovi.size()>=bovi.size()){ vector<int> tmp; for(int j=i;j<min(i+int(aovi.size()),n);j++){ tmp.push_back(aovi[j-i]); tmp.push_back(j); } int klkb=use_machine(tmp); i+=aovi.size()-1; int bio=klkb; if(klkb&1) bovi.push_back(tmp.back()); else aovi.push_back(tmp.back()); klkb=klkb/2+(klkb&1); int klka=tmp.size()/2-klkb; ret+=klka; if(bio&1) klkb--; if(klkb==int(tmp.size())/2-1) for(int j=1;j<int(tmp.size())-1;j+=2) bovi.push_back(tmp[j]); else if(klkb==0) for(int j=1;j<int(tmp.size())-1;j+=2) aovi.push_back(tmp[j]); }else if(bovi.size()>=w){ vector<int> tmp; for(int j=i;j<min(i+int(bovi.size()),n);j++){ tmp.push_back(bovi[j-i]); tmp.push_back(j); } int klka=use_machine(tmp); i+=bovi.size()-1; int bio=klka; if(klka&1) aovi.push_back(tmp.back()); else bovi.push_back(tmp.back()); klka=klka/2+(klka&1); ret+=klka; if(bio&1) klka--; if(klka==int(tmp.size())/2-1) for(int j=1;j<int(tmp.size())-1;j+=2) aovi.push_back(tmp[j]); else if(klka==0) for(int j=1;j<int(tmp.size())-1;j+=2) bovi.push_back(tmp[j]); }else if(aovi.size()>=2){ vector<int> tmp; for(int j=i;j<min(i+2,n);j++){ tmp.push_back(aovi[j-i]); tmp.push_back(j); } int klkb=use_machine(tmp); i+=aovi.size()-1; int bio=klkb; if(klkb&1) bovi.push_back(tmp.back()); else aovi.push_back(tmp.back()); klkb=klkb/2+(klkb&1); int klka=tmp.size()/2-klkb; ret+=klka; if(bio&1) klkb--; if(klkb==int(tmp.size())/2-1) for(int j=1;j<int(tmp.size())-1;j+=2) bovi.push_back(tmp[j]); else if(klkb==0) for(int j=1;j<int(tmp.size())-1;j+=2) aovi.push_back(tmp[j]); }else if(bovi.size()>=2){ vector<int> tmp; for(int j=i;j<min(i+2,n);j++){ tmp.push_back(bovi[j-i]); tmp.push_back(j); } int klka=use_machine(tmp); i+=bovi.size()-1; int bio=klka; if(klka&1) aovi.push_back(tmp.back()); else bovi.push_back(tmp.back()); klka=klka/2+(klka&1); ret+=klka; if(bio&1) klka--; if(klka==int(tmp.size())/2-1) for(int j=1;j<int(tmp.size())-1;j+=2) aovi.push_back(tmp[j]); else if(klka==0) for(int j=1;j<int(tmp.size())-1;j+=2) bovi.push_back(tmp[j]); }else{ int sta=use_machine({0,i}); if(sta==1) bovi.push_back(i); else aovi.push_back(i); } } return ret; }

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:14:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   14 |   if(aovi.size()>=w && aovi.size()>=bovi.size()){
      |      ~~~~~~~~~~~^~~
mushrooms.cpp:31:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |   }else if(bovi.size()>=w){
      |            ~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...