Submission #304207

# Submission time Handle Problem Language Result Execution time Memory
304207 2020-09-21T04:27:10 Z juggernaut Counting Mushrooms (IOI20_mushrooms) C++14
0 / 100
1 ms 256 KB
#include"mushrooms.h"
#include<bits/stdc++.h>
//#include"stub.cpp"
using namespace std;
int count_mushrooms(int n){
    vector<int>a,b,id;
    int i=1,res=1,j;
    for(;i<n;i++)id.push_back(i);
    srand(time(NULL));
    random_shuffle(id.begin(),id.end());
    i=0;
    a.push_back(0);
    while(i<n){
        if(a.size()>b.size()){
            vector<int>v;
            for(j=0;j<a.size()&&i+j<n;j++){
                v.push_back(a[j]);
                v.push_back(id[i+j]);
            }
            i+=j;
            j=use_machine(v);
            if(j&1)b.push_back(v.back());
            else a.push_back(v.back());
            j++;
            j>>=1;
            res+=(((int(v.size()))>>1))-j;
        }else{
            vector<int>v;
            for(j=0;j<b.size()&&i+j<n;j++){
                v.push_back(b[j]);
                v.push_back(id[i+j]);
            }
            i+=j;
            j=use_machine(v);
            if(j&1)a.push_back(v.back());
            else b.push_back(v.back());
            j++;
            j>>=1;
            res+=j;
        }
    }
    return res;
}

Compilation message

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:16:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |             for(j=0;j<a.size()&&i+j<n;j++){
      |                     ~^~~~~~~~~
mushrooms.cpp:29:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |             for(j=0;j<b.size()&&i+j<n;j++){
      |                     ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Answer is not correct.
2 Halted 0 ms 0 KB -