제출 #367534

#제출 시각아이디문제언어결과실행 시간메모리
367534rumen_m버섯 세기 (IOI20_mushrooms)C++17
0 / 100
148 ms772 KiB
#include "mushrooms.h" # include <bits/stdc++.h> using namespace std; vector <int> l[2]; const int K = 200000; int ans = 1; int count_mushrooms(int n) { int i,j; l[0].push_back(0); int x,y,type; vector <int> m; for(i=1;i<=2;i++) { m.clear(); m.push_back(0); m.push_back(i); int z = use_machine(m); l[z].push_back(i); } if(l[0].size()>=2) { type = 0; x = l[0][0]; y = l[0][1]; } else { type = 1; x = l[1][0]; y = l[1][1]; } i = 3; // l[0].push_back(0); while(i+1<n&&l[0].size()<K&&l[1].size()<K) { m.clear(); m.push_back(i); i++; m.push_back(x); m.push_back(i); i++; m.push_back(y); int z = use_machine(m); l[(z&1)^type].push_back(i-2); l[((z&10)>>1)^type].push_back(i-1); } //cout<<"Here"<<endl; ans = l[0].size(); while(i<n) { m.clear(); type = l[0].size()<l[1].size(); for(j=0;j<l[type].size()&&i<n;j++) { m.push_back(i); i++; m.push_back(l[type][j]); } int z = use_machine(m); l[(z&1)^type].push_back(m[0]); z = z/2+z%2; if(type==1)ans+=z; else ans+=(i-m[0]-z); } return ans; }

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

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