제출 #499933

#제출 시각아이디문제언어결과실행 시간메모리
499933Khizri버섯 세기 (IOI20_mushrooms)C++17
0 / 100
12 ms312 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; #define pb push_back int count_mushrooms(int n) { int k=0; int x=1; int ans=0; while(k<n){ int l=k,r=n-1; int q=k; while(l<=r){ int m=(l+r)/2; vector<int>vt; for(int i=q;i<=m;i++){ vt.pb(i); } int kk=0; if(vt.size()>1){ kk=use_machine(vt); } if(kk==vt.size()-1&&kk!=0){ if(x){ ans+=q-k+1; } for(int i=q+1;i<=m;i++){ x=1-x; if(x){ ans++; } } k=m+1; if(m+1<n&&use_machine({m,m+1})){ x=1-x; } goto loop; } if(kk==0){ l=m+1; q=m; } else{ r=m-1; } } if(x){ ans+=(l-1-k+1); } x=1-x; k=l; loop:; } return ans; }

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:22:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             if(kk==vt.size()-1&&kk!=0){
      |                ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...