Submission #860529

#TimeUsernameProblemLanguageResultExecution timeMemory
860529mychecksedadPacking Biscuits (IOI20_biscuits)C++17
42 / 100
1072 ms13504 KiB
// #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 < 100; ++i) a.pb(0);
	int n = a.size();

	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';
	}
	return ans;
}

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:44: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]
   44 |   for(int j = 0; j < pp.size(); ++j){
      |                  ~~^~~~~~~~~~~
biscuits.cpp:45: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]
   45 |    while(po < pp2.size() && pp2[po][0] < pp[j][0]){
      |          ~~~^~~~~~~~~~~~
biscuits.cpp:50: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]
   50 |    if(po < pp2.size() && pp2[po][0] == p.back()[0]){
      |       ~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...