Submission #860580

# Submission time Handle Problem Language Result Execution time Memory
860580 2023-10-13T10:59:58 Z mychecksedad Packing Biscuits (IOI20_biscuits) C++17
0 / 100
1000 ms 86500 KB
#include<biscuits.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
const int N = 1e6+100, M = 1e5+10, K = 22;

ll count_tastiness(ll x, vector<ll> a){
	for(int i = 0; i < 60; ++i) a.pb(0);
	int n = a.size();

	for(int i = 0; i < n - 1; ++i){
		if(a[i] >= x){
			a[i + 1] += (a[i]-x)>>1;
			a[i] -= (a[i]-x)>>1;
		}
	}

	ll ans = 1;
	vector<array<ll, 2>> p;
	p.pb({0ll, 1ll});

	for(int i = 0; i < n; ++i){
		vector<array<ll, 2>> pp, pp2;
		for(auto z: p){
			ll y = z[0];
			if(pp.empty() || pp.back()[0] != ((y+a[i])>>1)){
				pp.pb({(y+a[i])>>1, z[1]});
			}else if(pp.back()[0] == ((y+a[i])>>1)){
				pp.back()[1] += z[1];
			}

			if((y+a[i]-x) >= 0){
				if(pp2.empty() || pp2.back()[0] != ((y+a[i]-x)>>1)){
					pp2.pb({(y+a[i]-x)>>1, z[1]});
				}else if(pp2.back()[0] == ((y+a[i]-x)>>1)){
					pp2.back()[1] += z[1];
				}
				ans += z[1];

				// pp[(y+a[i]-x)>>1] += z.second;
				// ans += z.second;
			}
		}
		p.clear();
		int po = 0;
		for(int j = 0; j < pp.size(); ++j){
			while(po < pp2.size() && pp2[po][0] < pp[j][0]){
				p.pb(pp2[po]);
				++po;
			}
			p.pb(pp[j]);
			if(po < pp2.size() && pp2[po][0] == p.back()[0]){
				p.back()[1] += pp2[po][1];
				++po;
			}
		}
		// for(auto f: p) cout << f << ' ';
		// en;
	// cout << ans << '\n';
	}
	// cout << s << ' ';
	// cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n";
	return ans;
}

Compilation message

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:51:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |   for(int j = 0; j < pp.size(); ++j){
      |                  ~~^~~~~~~~~~~
biscuits.cpp:52:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |    while(po < pp2.size() && pp2[po][0] < pp[j][0]){
      |          ~~~^~~~~~~~~~~~
biscuits.cpp:57:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |    if(po < pp2.size() && pp2[po][0] == p.back()[0]){
      |       ~~~^~~~~~~~~~~~
# 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 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1018 ms 86500 KB Time limit exceeded
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 -