Submission #1033340

#TimeUsernameProblemLanguageResultExecution timeMemory
1033340happy_nodeCounting Mushrooms (IOI20_mushrooms)C++17
80.71 / 100
7 ms700 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int N) { vector<int> posA, posB; posA.push_back(0); int ans=posA.size(); for(int i=1;i<N;i++) { if(posA.size()>posB.size()) { int s=posA.size(); vector<int> qry; for(int j=i;j<min(N,i+s);j++) { qry.push_back(posA[j-i]); qry.push_back(j); } int w=use_machine(qry); if(w&1) posB.push_back(qry.back()); else posA.push_back(qry.back()); w=(w+1)/2; ans+=(qry.size()/2-w); i+=s-1; if(w==qry.size()/2) { for(int j=1;j+1<qry.size();j+=2) { posB.push_back(qry[j]); } } else if(w==0) { for(int j=1;j+1<qry.size();j+=2) { posA.push_back(qry[j]); } } } else { int s=posB.size(); vector<int> qry; for(int j=i;j<min(N,i+s);j++) { qry.push_back(posB[j-i]); qry.push_back(j); } int w=use_machine(qry); if(w&1) posA.push_back(qry.back()); else posB.push_back(qry.back()); w=(w+1)/2; if(w==qry.size()/2) { for(int j=1;j+1<qry.size();j+=2) { posA.push_back(qry[j]); } } else if(w==0) { for(int j=1;j+1<qry.size();j+=2) { posB.push_back(qry[j]); } } ans+=w; i+=s-1; } } return ans; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:28:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |    if(w==qry.size()/2) {
      |       ~^~~~~~~~~~~~~~
mushrooms.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int j=1;j+1<qry.size();j+=2) {
      |                 ~~~^~~~~~~~~~~
mushrooms.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int j=1;j+1<qry.size();j+=2) {
      |                 ~~~^~~~~~~~~~~
mushrooms.cpp:50:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |    if(w==qry.size()/2) {
      |       ~^~~~~~~~~~~~~~
mushrooms.cpp:51:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for(int j=1;j+1<qry.size();j+=2) {
      |                 ~~~^~~~~~~~~~~
mushrooms.cpp:55:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for(int j=1;j+1<qry.size();j+=2) {
      |                 ~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...