Submission #1080195

# Submission time Handle Problem Language Result Execution time Memory
1080195 2024-08-29T07:55:38 Z Muhammad_Aneeq Counting Mushrooms (IOI20_mushrooms) C++17
0 / 100
1 ms 432 KB
#include <vector>
#include <iostream>
using namespace std;
int use_machine(vector<int> x);
int count_mushrooms(int n)
{
    vector<int>sz[2]={};
    sz[0].push_back(0);
    int mx=94;
    for (int i=1;i<n;i++)
    {       
            sz[use_machine({0,i})].push_back(i);
            if (sz[0].size()>=mx||sz[1].size()>=mx)
                break;
    }
    if (sz[1]>sz[0])
        swap(sz[0],sz[1]);
    int cnt[2]={};
    cnt[0]=sz[0].size();
    for (int i=sz[0].size()+sz[1].size();i<n;i+=mx)
    {
        vector<int>qu;
        int f=min(i+mx,n)-i;
        for (int j=i;j<min(i+mx,n);j++)
        {
            qu.push_back(j);
            qu.push_back(sz[0][j-i]);
        }
        int x=use_machine(qu);
        cnt[0]+=f-(x+1)/2;
    }
    cnt[1]=n-cnt[0];
    if (sz[0][0]==0)
        return cnt[0];
    return cnt[1];
}

Compilation message

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:13:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |             if (sz[0].size()>=mx||sz[1].size()>=mx)
      |                 ~~~~~~~~~~~~^~~~
mushrooms.cpp:13:47: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |             if (sz[0].size()>=mx||sz[1].size()>=mx)
      |                                   ~~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 432 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Incorrect 1 ms 344 KB Duplicate value 0 in the query array.
7 Halted 0 ms 0 KB -