제출 #1011319

#제출 시각아이디문제언어결과실행 시간메모리
1011319lev1106버섯 세기 (IOI20_mushrooms)C++17
0 / 100
6 ms344 KiB
#include <cstdio> #include <cstdlib> #include <cstdarg> #include <string> #include "mushrooms.h" #include <vector> #include <iostream> int sz = 100; int count_mushrooms(int n) { int cnt = 1, i = 0; bool cur = 0; std::vector<int> v0, v1; v0.push_back(0); for (i = 0; i <= n - 2; i++) { if (use_machine({i, i + 1})) cur ^= 1; if (!cur) cnt++, v0.push_back(i + 1); else v1.push_back(i + 1); if (std::max(v0.size(), v1.size()) >= sz + 1) { i += 2; break; } } bool sw = 0; if (v0.size() < v1.size()) swap(v0, v1), sw = 1; for (; i < n - 1; i++) { //std::cout << i << "!!!\n"; std::vector<int> v; for (int j = i; j <= std::min(i + sz, n) - 1; j++) { v.push_back(v0[j - i]); v.push_back(j); } v.push_back(v0[sz]); //for (auto j : v) std::cout << j << " "; //std::cout << " ||| " << 10 - use_machine(v) << " " << 10 - use_machine(v) / 2 << "\n"; if (!sw) cnt += v.size() / 2 - use_machine(v) / 2; else cnt += use_machine(v) / 2; i += sz - 1; } return cnt; }

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:19:38: warning: comparison of integer expressions of different signedness: 'const long unsigned int' and 'int' [-Wsign-compare]
   19 |   if (std::max(v0.size(), v1.size()) >= sz + 1) {
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...