Submission #304023

# Submission time Handle Problem Language Result Execution time Memory
304023 2020-09-21T01:05:52 Z Fdg Counting Mushrooms (IOI20_mushrooms) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
// #include "mushrooms.h"

using namespace std;

const int VAL = 141;

vector<int> a, b;

int count_mushrooms(int n) {
  srand(time(NULL));
  vector<int> v;
  for (int i = 1; i < n; ++i)
    v.push_back(i);
  random_shuffle(v.begin(), v.end());

  int ans = 0, pos = 0;

  a.push_back(0);
  while (pos < v.size()/*a.size() < VAL || b.size() < VAL*/) {
    if (a.size() > 1) {
      vector<int> arr = {a[0]};
      if (pos < v.size()) arr.push_back(v[pos]), ++pos;
      arr.push_back(a[1]); 
      if (pos < v.size()) arr.push_back(v[pos]), ++pos;

      int ret = use_machine(arr);
      if (ret & 2) {
        b.push_back(arr[1]);
      } else {
        a.push_back(arr[1]);
      }
      if (ret & 1) {
        b.push_back(arr[3]);
      } else {
        a.push_back(arr[3]);
      }
    } else if (b.size() > 1) {
      vector<int> arr = {b[0]};
      if (pos < v.size()) arr.push_back(v[pos]), ++pos;
      arr.push_back(b[1]); 
      if (pos < v.size()) arr.push_back(v[pos]), ++pos;

      int ret = use_machine(arr);
      if (ret & 2) {
        a.push_back(arr[1]);
      } else {
        b.push_back(arr[1]);
      }
      if (ret & 1) {
        a.push_back(arr[3]);
      } else {
        b.push_back(arr[3]);
      }
    } else {
      vector<int> arr = {a[0]};
      if (pos < v.size()) arr.push_back(v[pos]), ++pos;

      int ret = use_machine(arr);
      if (ret & 1) {
        b.push_back(arr[1]);
      } else {
        a.push_back(arr[1]);
      }
    }
  }

  ans = a.size();

  return ans;
}

Compilation message

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:24:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   while (pos < v.size()/*a.size() < VAL || b.size() < VAL*/) {
      |          ~~~~^~~~~~~~~~
mushrooms.cpp:27:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |       if (pos < v.size()) arr.push_back(v[pos]), ++pos;
      |           ~~~~^~~~~~~~~~
mushrooms.cpp:29:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |       if (pos < v.size()) arr.push_back(v[pos]), ++pos;
      |           ~~~~^~~~~~~~~~
mushrooms.cpp:31:17: error: 'use_machine' was not declared in this scope
   31 |       int ret = use_machine(arr);
      |                 ^~~~~~~~~~~
mushrooms.cpp:44:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |       if (pos < v.size()) arr.push_back(v[pos]), ++pos;
      |           ~~~~^~~~~~~~~~
mushrooms.cpp:46:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |       if (pos < v.size()) arr.push_back(v[pos]), ++pos;
      |           ~~~~^~~~~~~~~~
mushrooms.cpp:48:17: error: 'use_machine' was not declared in this scope
   48 |       int ret = use_machine(arr);
      |                 ^~~~~~~~~~~
mushrooms.cpp:61:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |       if (pos < v.size()) arr.push_back(v[pos]), ++pos;
      |           ~~~~^~~~~~~~~~
mushrooms.cpp:63:17: error: 'use_machine' was not declared in this scope
   63 |       int ret = use_machine(arr);
      |                 ^~~~~~~~~~~