제출 #781511

#제출 시각아이디문제언어결과실행 시간메모리
781511_martynas비스킷 담기 (IOI20_biscuits)C++14
12 / 100
1 ms616 KiB
#include "biscuits.h"
#include <set>
#include <iostream>
#include <assert.h>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;

#warning change mxk to 60
const int mxk = 60;

ll count_tastiness(ll x, vector<ll> a) {
    assert(x == 1);
    vector<ll> dp(mxk+1); // dp[i] - ways to use first i bits
    dp[0] = 1;
    a.resize(mxk, 0);
    vector<ll> pref(mxk);
    for(int i = 0; i < mxk; i++) {
        pref[i] = (i ? pref[i-1] : 0) + (1LL<<i)*a[i];
    }
//    for(int y : a) cerr << y << " ";
//    cerr << "\n";
    for(int i = 1; i <= mxk; i++) {
        // i-th bit is 0
        dp[i] = dp[i-1];
        // i-th bit is 1
        if(a[i-1] > 0) {
            dp[i] += dp[i-1];
        }
        else {
            ll mx = 1LL << (i-1);
            mx = pref[i-1]-mx;
            if(mx >= (1LL << (i-1))) {
                dp[i] += dp[i-1];
            }
            else if(mx >= 0) {
                dp[i]++;
                for(int b = 0; b < i-1; b++) {
                    if(mx & (1LL << b)) {
                        dp[i] += dp[b];
                    }
                }
            }
        }
    }
//    for(auto y : dp) cerr << y << " ";
//    cerr << "\n";
	return dp[mxk];
}

컴파일 시 표준 에러 (stderr) 메시지

biscuits.cpp:12:2: warning: #warning change mxk to 60 [-Wcpp]
   12 | #warning change mxk to 60
      |  ^~~~~~~
#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...