Submission #877658

# Submission time Handle Problem Language Result Execution time Memory
877658 2023-11-23T12:13:48 Z abczz Packing Biscuits (IOI20_biscuits) C++14
0 / 100
1 ms 348 KB
#include "biscuits.h"
#include <iostream>
#include <vector>
#define ll long long
#define ull __int128

using namespace std;

ll dp[60][60][2], f;

long long count_tastiness(long long x, std::vector<long long> a) {
	vector <ull> V;
	ull z = x, s = 1, y = 1;
	f = 0;
	for (auto u : a) V.push_back(u);
	for (int i=0; i<V.size(); ++i) {
		s *= 2;
		y *= 2;
		for (int j=0; j<i; ++j) {
			V[i] *= 2;
		}
		if (i) V[i] += V[i-1];
	}
	for (int i=0; i<V.size(); ++i) {
		for (int j=0; j<V.size(); ++j) {
			dp[i][j][0] = dp[i][j][1] = 0;
		}
	}
	for (int i=0; i<V.size(); ++i) {
		V[i] /= z;
	}
	y /= 2;
	if ((V.back() & y)) ++dp[V.size()-1][V.size()-1][0];
	++dp[V.size()-1][V.size()-1][1];
	for (int i=V.size()-1; i>0; --i) {
		y /= 2;
		s /= 2;
		for (int j=i; j<V.size(); ++j) {
			//cout << i << " " << j << " " << dp[i][j][0] << endl;
			//cout << i << " " << j << " " << dp[i][j][1] << endl;
			if ((V[i-1] & y)) dp[i-1][i-1][0] += dp[i][j][0];
			dp[i-1][i-1][1] += dp[i][j][0];
			if ((V[j] & (s-1)) <= (V[i-1] & (s-1))) {
				if ((V[j] & y)) dp[i-1][j][0] += dp[i][j][1];
				dp[i-1][j][1] += dp[i][j][1];
			}
			else {
				if ((V[i-1] & y)) dp[i-1][i-1][0] += dp[i][j][1];
				dp[i-1][i-1][1] += dp[i][j][1];
			}
		}
	}
	for (int i=0; i<V.size(); ++i) {
		f += dp[0][i][0] + dp[0][i][1];
	}
	return f;
}

Compilation message

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:16:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<__int128>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  for (int i=0; i<V.size(); ++i) {
      |                ~^~~~~~~~~
biscuits.cpp:24:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<__int128>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  for (int i=0; i<V.size(); ++i) {
      |                ~^~~~~~~~~
biscuits.cpp:25:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<__int128>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   for (int j=0; j<V.size(); ++j) {
      |                 ~^~~~~~~~~
biscuits.cpp:29:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<__int128>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  for (int i=0; i<V.size(); ++i) {
      |                ~^~~~~~~~~
biscuits.cpp:38:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<__int128>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   for (int j=i; j<V.size(); ++j) {
      |                 ~^~~~~~~~~
biscuits.cpp:53:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<__int128>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |  for (int i=0; i<V.size(); ++i) {
      |                ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -