답안 #304024

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
304024 2020-09-21T01:06:08 Z Fdg 버섯 세기 (IOI20_mushrooms) C++14
0 / 100
1 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) {
  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: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: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;
      |           ~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Incorrect 1 ms 256 KB Answer is not correct.
6 Halted 0 ms 0 KB -