이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#include "biscuits.h"
using ll = long long;
using lll = __int128;
struct node {
lll mn, mx, ad, sz;
node *l, *r;
};
using seq = node*;
seq con(lll n, lll v) {
return n == 0 ? nullptr : new node{v, v, 0, n, nullptr, nullptr};
}
seq inc(seq s, lll a) {
return a == 0 ? s : new node{s->mn, s->mx, s->ad + a, s->sz, s->l, s->r};
}
seq conc(seq l, seq r, lll ad = 0) {
if (l == nullptr) return inc(r, ad);
if (r == nullptr) return inc(l, ad);
assert(l->mx + l->ad <= r->mn + r->ad);
return new node{l->mn + l->ad, r->mx + r->ad, ad, l->sz + r->sz, l, r};
}
seq drop(seq s, lll u = 0) {
u -= s->ad;
return s->mx < u ? nullptr : u <= s->mn ? s : conc(drop(s->l, u), drop(s->r, u), s->ad);
}
lll size(seq s) {
return s->sz;
}
ll count_tastiness(ll x, vector<ll> a) {
a.resize(a.size() + 3);
auto s = con(1, 0);
for (int i = 0; i < a.size(); i++) s = drop(conc(inc(s, lll(-x) << i), s, lll(a[i]) << i));
return size(s);
}
컴파일 시 표준 에러 (stderr) 메시지
biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for (int i = 0; i < a.size(); i++) s = drop(conc(inc(s, lll(-x) << i), s, lll(a[i]) << i));
| ~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |