Submission #1059324

#TimeUsernameProblemLanguageResultExecution timeMemory
1059324c2zi6비스킷 담기 (IOI20_biscuits)C++14
21 / 100
1074 ms440 KiB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "biscuits.h"

namespace TEST1 {
    ll count_tastiness(ll k, VL a) {
        int MAXBIT = 60;
        while (a.size() < MAXBIT) a.pb(0);
        ll sum = 0;
        rep(i, MAXBIT) sum += a[i] * (1ll<<i);
        ll ans = 0;
        for (ll y = 0; y <= sum; y++) {
            ll cur = 0;
            rep(i, MAXBIT) {
                cur += a[i];
                if (y & (1ll<<i)) {
                    if (cur < k) goto vat;
                    cur -= k;
                }
                cur /= 2;
            }
            ans++;
            vat:;
        }
        return ans;
    }
};

namespace TEST2 {
    ll count_tastiness(ll k, VL a) {
        int MAXBIT = 62;
        while (a.size() < MAXBIT) a.pb(0);
        rep(i, MAXBIT) {
            if (a[i] & 1) {
                a[i+1] += (a[i]-1)/2;
                a[i] = 1;
            } else if (a[i] >= 2) {
                a[i+1] += (a[i]-2)/2;
                a[i] = 2;
            }
        }
        ll ans = 1;
        ll mek = 0;
        int cnt = 0;

        ll cur = 0;

        a.pb(0);
        rep(i, MAXBIT) {
            if (i == 0 || a[i-1] == 0) cnt = 0;
            if (a[i]) {
                if (a[i] == 2) cur += (1ll<<cnt);
                cnt++;
                if (a[i+1] == 0) cur += (1ll<<cnt);

                if (a[i+1] == 0) {
                    ans *= cur;
                    cur = 0;
                }
            }
        }

        return ans;
    }
};

ll count_tastiness(ll x, VL a) {
    /*ll ans1 = TEST1::count_tastiness(x, a);*/
    /*ll ans2 = TEST2::count_tastiness(x, a);*/
    /*cout << "REAL ANSWER / MY ANSWER : " << ans1 << " / " << ans2 << endl;*/
    /*return -1;*/

    if (x == 1) return TEST2::count_tastiness(x, a);
    return TEST1::count_tastiness(x, a);
}


Compilation message (stderr)

biscuits.cpp: In function 'll TEST1::count_tastiness(ll, VL)':
biscuits.cpp:37:25: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |         while (a.size() < MAXBIT) a.pb(0);
      |                ~~~~~~~~~^~~~~~~~
biscuits.cpp: In function 'll TEST2::count_tastiness(ll, VL)':
biscuits.cpp:61:25: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   61 |         while (a.size() < MAXBIT) a.pb(0);
      |                ~~~~~~~~~^~~~~~~~
biscuits.cpp:72:12: warning: unused variable 'mek' [-Wunused-variable]
   72 |         ll mek = 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...