Submission #304026

# Submission time Handle Problem Language Result Execution time Memory
304026 2020-09-21T01:07:43 Z Fdg Counting Mushrooms (IOI20_mushrooms) C++14
0 / 100
0 ms 256 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) {
  a.clear(); b.clear();
  
  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 < (int) v.size()/*a.size() < VAL || b.size() < VAL*/) {
    if (a.size() > 1) {
      vector<int> arr = {a[0]};
      if (pos < (int) v.size()) arr.push_back(v[pos]), ++pos;
      arr.push_back(a[1]); 
      if (pos < (int) 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 < (int) v.size()) arr.push_back(v[pos]), ++pos;
      arr.push_back(b[1]); 
      if (pos < (int) 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 < (int) 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;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Answer is not correct.
3 Halted 0 ms 0 KB -