제출 #828672

#제출 시각아이디문제언어결과실행 시간메모리
828672Minindu206버섯 세기 (IOI20_mushrooms)C++14
0 / 100
2 ms208 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int n) { vector<int> posa, posb, pos; int acnt = 1, bcnt = 0, cnt, ans = 0; posa.push_back(0); for (int i = 1; i < min(200, n); i++) { int cur = use_machine({0, i}); if (cur == 0) { if (acnt < 97) posa.push_back(i); acnt++; } else { if (bcnt < 97) posb.push_back(i); bcnt++; ans++; } } if (n <= 200) { return n - ans; } if (acnt >= bcnt) pos = posa; else pos = posb; int i = 200; vector<int> chk; while (i < n) { chk.clear(); int cur = 0, vr = i + cnt; for(;i<vr && cur < pos.size();i++) { chk.push_back(i); chk.push_back(pos[cur]); cur++; } int ncur = use_machine(chk); if (acnt >= bcnt) ans += (ncur + 1) / 2; else ans += (cur - ((ncur + 1) / 2)); } return n - ans; }

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:42:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   for(;i<vr && cur < pos.size();i++)
      |                ~~~~^~~~~~~~~~~~
mushrooms.cpp:41:16: warning: 'cnt' may be used uninitialized in this function [-Wmaybe-uninitialized]
   41 |   int cur = 0, vr = i + cnt;
      |                ^~
#Verdict Execution timeMemoryGrader output
Fetching results...