Submission #1076573

#TimeUsernameProblemLanguageResultExecution timeMemory
1076573blushingecchigirl비스킷 담기 (IOI20_biscuits)C++17
0 / 100
1 ms524 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

ll bin_exp(ll n, ll p) {
    ll res = 0;
    while(p) {
        if(p&1) res+=n;
        n*=n;
        p/=2;
    }
    return res;
}

ll count_tastiness(ll x, std::vector<ll> a) {
    for(int i = 0; i<a.size(); i++) a[i]/=x;
    for(int i = 0; i<a.size(); i++) {
        if(a[i] && i == a.size()-1) a.pb(0);
        if(a[i]>2) {
            if(a[i]%2) {
                a[i+1]+=(a[i]-1)/2;
                a[i] = 1;
            } else {
                a[i+1]+=(a[i]-2)/2;
                a[i] = 2;
            }
        }
    }
    ll ans = 1, cur = 0, p = 0;
    for(int i = 0; i<a.size(); i++) {
        if(a[i] == 0 || a[i] == 2) cur+=bin_exp(2, i-p);
        if(a[i] == 0) {
            ans*=cur;
            cur = 0;
            p = i+1;
        }
    }
    return ans;
}

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:17:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i = 0; i<a.size(); i++) a[i]/=x;
      |                    ~^~~~~~~~~
biscuits.cpp:18:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for(int i = 0; i<a.size(); i++) {
      |                    ~^~~~~~~~~
biscuits.cpp:19:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         if(a[i] && i == a.size()-1) a.pb(0);
      |                    ~~^~~~~~~~~~~~~
biscuits.cpp:31:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i = 0; i<a.size(); i++) {
      |                    ~^~~~~~~~~
#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...