Submission #884483

# Submission time Handle Problem Language Result Execution time Memory
884483 2023-12-07T13:33:15 Z weajink Counting Mushrooms (IOI20_mushrooms) C++17
0 / 100
0 ms 344 KB
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#ifdef LOCAL
#define debug(...) __VA_ARGS__
#else
#define debug(...) {}
#endif

int count_mushrooms(int n){
    vector<int> znane[2];
    znane[0].push_back(0);
    int ile[2] = {0};
    int akt = 1;
    while (akt < n){
        bool better = (znane[0].size()<znane[1].size());
        int pt = 0;
        vector<int> zap;
        for (; akt < n && pt < znane[better].size(); akt++,pt++){
            zap.push_back(znane[better][pt]);
            zap.push_back(akt);
        }
        int wy = use_machine(zap);
        if (wy%2) znane[!better].push_back(akt-1);
        else znane[better].push_back(akt-1);
        ile[better] += pt-(wy+1)/2;
        ile[!better] += (wy+1)/2;
    }
    return ile[0];
}

Compilation message

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:20:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         for (; akt < n && pt < znane[better].size(); akt++,pt++){
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Answer is not correct.
2 Halted 0 ms 0 KB -