Submission #329247

# Submission time Handle Problem Language Result Execution time Memory
329247 2020-11-20T00:25:27 Z nikatamliani Packing Biscuits (IOI20_biscuits) C++14
12 / 100
7 ms 492 KB
#include <bits/stdc++.h>
#include "biscuits.h"
using namespace std;
using ll = long long;
ll count_tastiness(ll x, vector<ll> a) {
	ll ans = 1;
	for(int i = 0; i < (int)a.size() - 1; ++i) {
		ll sub = (a[i] - 1) / 2 * 2;
		a[i+1] += sub / 2;
		a[i] -= sub; 
	}
	while(true) {
		ll sub = (a.back() - 1) / 2 * 2;
		if(!sub) break;
		a.back() -= sub; 
		a.push_back(sub / 2);
	}
	a.insert(a.begin(), 0);
	int n = a.size();
	vector<vector<vector<ll>>> dp(n+1, vector<vector<ll>>(2, vector<ll>(2, 0)));
	dp[0][0][0] = 1; 
	for(int i = 0; i < n; ++i) {
		bool added[2][2][2];
		memset(added, 0, sizeof added);
		for(int he = 0; he < 2; ++he) {
			for(int me = 0; me < 2; ++me) {
				for(int take = 0; take <= a[i]; ++take) {
					int new_me = take + me;
					int new_he = new_me / 2;
					new_me -= new_he * 2;
					if(added[he][new_me][new_he]) continue;
					added[he][new_me][new_he] = 1;
					dp[i+1][new_me][new_he] += dp[i][he][me];
				}
			}
		}
	}
	return dp[n][0][0] + dp[n][1][0] + dp[n][0][1] + dp[n][1][1];
}

Compilation message

biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:6:5: warning: unused variable 'ans' [-Wunused-variable]
    6 |  ll ans = 1;
      |     ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -