Submission #331889

#TimeUsernameProblemLanguageResultExecution timeMemory
331889pggpCounting Mushrooms (IOI20_mushrooms)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "mushrooms.h" using namespace std; vector < bool > mushrooms; int use_machine(vector < int > x); int c; int count_mushrooms(int n){ int ans = 1; if(n < 200){ for (int i = 1; i < n; ++i) { vector < int > v; v.push_back(0); v.push_back(i); ans += 1 - use_machine(v); } return ans; } vector < int > A_pos; vector < int > B_pos; for (int i = 1; i < 200; ++i) { vector < int > v; v.push_back(0); v.push_back(i); int t = use_machine(v); if(t){ B_pos.push_back(i); } else{ A_pos.push_back(i); } } int cur = 200; if(A_pos.size() > B_pos.size()){ while(cur < n){ int in_heap = 0; vector < int > v; v.push_back(0); for(int i = 1; i < A_pos.size() - 1; i++){ v.push_back(cur); in_heap++; v.push_back(A_pos[i]); cur++; if(cur == n){ break; } } v.push_back(A_pos[A_pos.size() - 1]); int resp = use_machine(v); ans += in_heap - resp/2; } } else{ while(cur < n){ vector < int > v; v.push_back(0); v.push_back(B_pos[0]); for(int i = 1; i < B_pos.size(); i++){ v.push_back(cur); v.push_back(B_pos[i]); cur++; if(cur == n){ break; } } int resp = use_machine(v); ans += (resp-1)/2; } } return ans + A_pos.size(); } int use_machine(vector < int > x){ c++; int ans = 0; for (int i = 0; i < x.size() - 1; ++i) { if(mushrooms[x[i]] != mushrooms[x[i + 1]]){ ans++; } } return ans; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:48:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |    for(int i = 1; i < A_pos.size() - 1; i++){
      |                   ~~^~~~~~~~~~~~~~~~~~
mushrooms.cpp:68:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |    for(int i = 1; i < B_pos.size(); i++){
      |                   ~~^~~~~~~~~~~~~~
mushrooms.cpp: In function 'int use_machine(std::vector<int>)':
mushrooms.cpp:88:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |  for (int i = 0; i < x.size() - 1; ++i)
      |                  ~~^~~~~~~~~~~~~~
/tmp/ccklxTjp.o: In function `use_machine(std::vector<int, std::allocator<int> >)':
stub.cpp:(.text+0x210): multiple definition of `use_machine(std::vector<int, std::allocator<int> >)'
/tmp/ccAHjzvl.o:mushrooms.cpp:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status