제출 #824257

#제출 시각아이디문제언어결과실행 시간메모리
824257thimote75버섯 세기 (IOI20_mushrooms)C++14
56.36 / 100
9 ms336 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; using idata = vector<int>; const int QK = 186; int count_mushrooms(int n) { idata Av = { 0 }; idata Bv = { }; for (int i = 1; i < n && i < QK; i ++) { int res = use_machine({ 0, i }); if (res == 0) Av.push_back(i); else Bv.push_back(i); } int offset = 0; int multiplier = 1; if (Bv.size() > Av.size()) { Bv.swap(Av); offset = n; multiplier = -1; } int total = Av.size(); for (int i = QK; i < n; i += Av.size() - 1) { idata templ; int cnt = 0; for (int j = 0; j < Av.size() - 1; j ++) { templ.push_back(Av[j]); if (i + j >= n) continue ; cnt ++; templ.push_back(i + j); } templ.push_back(Av[Av.size() - 1]); int res = use_machine(templ); int c0 = (cnt) - (res >> 1); total += c0; } return offset + multiplier * total; }

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

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