Submission #303991

# Submission time Handle Problem Language Result Execution time Memory
303991 2020-09-20T22:58:34 Z Fdg Packing Biscuits (IOI20_biscuits) C++14
0 / 100
1000 ms 72020 KB
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

vector<long long> trans(const vector<long long>& a, long long sub) {
  vector<long long> na = a;
  na.pop_back();
  if (a.back() - sub > 1) {
    long long val = (a.back() - sub) / 2;
    if (na.size() == 0) na.push_back(val);
    else na.back() += val;
  }
  return na;
}

map<vector<long long>, long long> f;

long long solve(long long x, vector<long long> a) {
  if (a.size() == 0) return 1;
  if (f.count(a)) return f[a];

  long long ret = 0;
  if (a.back() >= x) {
    ret += solve(x, trans(a, x));
  }

  ret += solve(x, trans(a, 0));
  return f[a] = ret;
}

long long count_tastiness(long long x, vector<long long> a) {
  f.clear();

  for (int i = 0; i < a.size(); ++i) {
    if (a[i] > x) {
      long long add = (a[i] - x) / 2;
      a[i] = x;
      if (i + 1 == (int) a.size())
        a.push_back(add);
      else
        a[i + 1] += add;
    }
  }

  reverse(a.begin(), a.end());
  return solve(x, a);
}

Compilation message

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:38:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   for (int i = 0; i < a.size(); ++i) {
      |                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1098 ms 72020 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 33968 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -