제출 #624890

#제출 시각아이디문제언어결과실행 시간메모리
624890cfalas버섯 세기 (IOI20_mushrooms)C++17
89.33 / 100
9 ms400 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int n) { vector<int> arr[2]; bool B = 1; int i,k,x; const int init = 80; vector<int> temp; temp.push_back(0); arr[0].push_back(0); int res = 0; for(i=1;i<=min(n-1,2);i++){ temp.push_back(i); x = use_machine(temp); temp.pop_back(); arr[x].push_back(i); } temp.pop_back(); if(arr[0].size() > arr[1].size()) B = 0; //assert(arr[B].size() >= 2); temp.push_back(arr[B][0]); temp.push_back(-1); if(arr[B].size() > 1){ temp.push_back(arr[B][1]); } temp.push_back(-1); for(k=3;k<=min(n-2,init-1);k+=2){ temp[1] = k; temp[3] = k+1; x = use_machine(temp); if(x >= 2){ /// middle one is different arr[B^1].push_back(k); } else{ arr[B].push_back(k); } if(x % 2){ /// right one is diff arr[B^1].push_back(k+1); } else{ arr[B].push_back(k+1); } } if(n%2 == 0 && k == n-1 && n != 2){ temp = {0,n-1}; x = use_machine(temp); if(!x)res++; } k = init + 1; res += arr[0].size(); while(k<n){ temp.clear(); B = 1; if(arr[0].size() > arr[1].size()) B = 0; for(i=0;i<arr[B].size() && k < n;i++){ temp.push_back(arr[B][i]); temp.push_back(k); k++; } x = use_machine(temp); int diff = x/2; if(x%2){ diff++; arr[B^1].push_back(temp.back()); } else{ arr[B].push_back(temp.back()); } if(B) res += diff; else res += temp.size()/2 - diff; } return res; }

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

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