Submission #748216

# Submission time Handle Problem Language Result Execution time Memory
748216 2023-05-25T16:41:29 Z DJeniUp Counting Mushrooms (IOI20_mushrooms) C++17
0 / 100
21 ms 828 KB
#include "mushrooms.h"
#include "bits/stdc++.h"

using namespace std;

typedef int ll;

#define pb push_back

ll S(vector<ll>v,ll x,ll y){
    if(v.size()==1)return x^1;
    vector<ll>a(0),b(0);
    for(int i=0;i<v.size();i++){
        if(i%2==0 && i!=v.size()-1){
            a.pb(v[i]);
        }else{
            b.pb(v[i]);
        }
    }
    //cout<<a.size()<<" "<<b.size()<<endl;
    
    ll r1=0;
    ll res1=0;
    if(a.size()>1){
        r1=use_machine(a);
        res1=(r1/2+1)+(r1+1)/2;
        if(res1==a.size()){
            if(x==0)res1=(r1/2+1);
            else res1=(r1+1)/2;
        }else if(r1==0){
            if(x==0)res1=a.size();
            else res1=0;
        }else{
            if(r1%2==0){
                res1=S(a,x,x);
            }else res1=S(a,x,x^1);
        }
    }else res1=x^1;
    ll r2=0;
    ll res2=0;
    if(b.size()>1){
        r2=use_machine(b);
        res2=(r2/2+1)+(r2+1)/2;
        if(res2==b.size()){
            if(y==0)res2=(r2/2+1);
            else res2=(r2+1)/2;
        }else if(r2==0){
            if(y==0)res2=b.size();
            else res2=0;
        }else{
            if(r2%2==0){
                res2=S(b,y,y);
            }else res2=S(b,y^1,y);
        }
    }else res2=y^1;
    return res1+res2;
}

int count_mushrooms(int n) {
    vector<ll>v(n);
    for(int i=0;i<n;i++){
        v[i]=i;
    }
    ll g=use_machine(v);
    if(g%2==0)return S(v,0,0);
    else return S(v,0,1);
}

Compilation message

mushrooms.cpp: In function 'll S(std::vector<int>, ll, ll)':
mushrooms.cpp:13:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
mushrooms.cpp:14:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |         if(i%2==0 && i!=v.size()-1){
      |                      ~^~~~~~~~~~~~
mushrooms.cpp:27:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         if(res1==a.size()){
      |            ~~~~^~~~~~~~~~
mushrooms.cpp:44:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         if(res2==b.size()){
      |            ~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 2 ms 208 KB Output is correct
6 Partially correct 21 ms 324 KB Output is partially correct
7 Incorrect 10 ms 828 KB Too many total array sizes as queries.
8 Halted 0 ms 0 KB -