Submission #933959

# Submission time Handle Problem Language Result Execution time Memory
933959 2024-02-26T15:36:37 Z EJIC_B_KEDAX Counting Mushrooms (IOI20_mushrooms) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "mushrooms.h"

using ll = long long;

using namespace std;

mt19937 mt();

int count_mushrooms(int n) {
    vector<int> p(n - 1);
    for (int i = 0; i < n - 1; i++) {
        p[i] = i + 1;
    }
    shuffle(p.begin(), p.end(), mt);
    vector<int> a(1, 0), b;
    int x = 0, ans = 1;
    while (x < n - 1) {
        vector<int> ask;
        if (a.size() > b.size()) {
            int ind = 0, len = -1, start = x;
            while (x < n - 1 && ind < a.size()) {
                ask.push_back(a[ind++]);
                ask.push_back(p[x++]);
                len++;
            }
            int cnt = use_machine(ask);
            if (cnt & 1) {
                b.push_back(p[x - 1]);
                cnt--;
            } else {
                a.push_back(p[x - 1]);
                ans++;
            }
            if (!cnt) {
                for (int i = start; i < x - 1; i++) {
                    ans++;
                    a.push_back(p[i]);
                }
            } else if (cnt == 2 * len) {
                for (int i = start; i < x - 1; i++) {
                    b.push_back(p[i]);
                }
            }
        } else {
            int ind = 0, len = -1, start = x;
            while (x < n - 1 && ind < b.size()) {
                ask.push_back(b[ind++]);
                ask.push_back(p[x++]);
                len++;
            }
            int cnt = use_machine(ask);
            if (cnt & 1) {
                a.push_back(p[x - 1]);
                ans++;
                cnt--;
            } else {
                b.push_back(p[x - 1]);
            }
            if (!cnt) {
                for (int i = start; i < x - 1; i++) {
                    b.push_back(p[i]);
                }
            } else if (cnt == 2 * len) {
                for (int i = start; i < x - 1; i++) {
                    a.push_back(p[i]);
                    ans++;
                }
            }
        }
    }
    return ans;
}

Compilation message

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:22:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             while (x < n - 1 && ind < a.size()) {
      |                                 ~~~~^~~~~~~~~~
mushrooms.cpp:47:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |             while (x < n - 1 && ind < b.size()) {
      |                                 ~~~~^~~~~~~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from mushrooms.cpp:1:
/usr/include/c++/10/bits/stl_algo.h: In instantiation of 'void std::shuffle(_RAIter, _RAIter, _UGenerator&&) [with _RAIter = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _UGenerator = std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253> (&)()]':
mushrooms.cpp:15:35:   required from here
/usr/include/c++/10/bits/stl_algo.h:3769:2: error: 'std::remove_reference<std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253> (&)()>::type' {aka 'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>()'} is not a class, struct, or union type
 3769 |  __uc_type;
      |  ^~~~~~~~~
/usr/include/c++/10/bits/stl_algo.h:3797:37: error: 'std::remove_reference<std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253> (&)()>::type' {aka 'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>()'} is not a class, struct, or union type
 3797 |    const pair<__uc_type, __uc_type> __pospos =
      |                                     ^~~~~~~~
/usr/include/c++/10/bits/stl_algo.h:3797:37: error: 'std::remove_reference<std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253> (&)()>::type' {aka 'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>()'} is not a class, struct, or union type