QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#446214 | #8578. 과일 게임 | Wansur | 0 | 2008ms | 744676kb | C++23 | 4.5kb | 2024-06-17 01:40:56 | 2024-06-17 01:40:57 |
Judging History
answer
#include <bits/stdc++.h>
#define f first
#define s second
#define ent '\n'
using namespace std;
typedef long long ll;
int get(deque<pair<int, int>> dq){
int ans = 0;
for(int i=0;i+1<dq.size();i++){
if(dq[i].f > dq[i+1].f){
break;
}
dq[i+1].s += (dq[i].s >> (dq[i+1].f - dq[i].f));
}
for(int i=dq.size()-1;i>=1;i--){
if(dq[i].f > dq[i-1].f){
continue;
}
dq[i-1].s += (dq[i].s >> (dq[i-1].f - dq[i].f));
}
for(auto [x, y]:dq){
while(y > 1){
x++;
y /= 2;
}
ans = max(ans, x);
}
return ans;
}
struct asd{
deque<pair<int, int>> pref, suff;
bool same;
int mx = 0;
asd(){
pref.clear(), suff.clear();
same = 1;
mx = 0;
}
asd(int x){
pref = suff = {{x, 1}};
same = 1;
mx = x;
}
bool insert(pair<int, int> T){
auto [x, c] = T;
if(suff.size() && suff.back().f == x){
suff[suff.size()-1].s += c;
if(same){
pref[pref.size()-1].s += c;
}
return 0;
}
while(suff.size() > 1 && suff[suff.size()-2].f > suff.back().f && suff.back().f < x){
if(suff.back().s % 2 == 0){
auto [x, y] = suff.back();
suff.pop_back();
if(x+1 == suff.back().f){
suff.back().s += y/2;
}
else{
suff.push_back({x+1, y / 2});
}
continue;
}
if(same){
same = 0;
auto [x, y] = pref.back();
pref.pop_back();
if(pref.size() && pref.back().f == x+1){
pref.back().f += y / 2;
}
else{
if(y > 1) pref.push_back({x+1, y/2});
}
if(y % 2){
pref.push_back({x, 1});
}
mx = max(mx, get(pref));
}
while(suff.size() > 1){
suff.pop_front();
}
int v = x;
auto [x, y] = suff.back();
suff.pop_back();
if(y % 2){
suff.push_back({x, 1});
}
if(y > 1){
suff.push_back({x, y / 2});
}
if(suff.back().f == v){
suff.back().s++;
}
else{
suff.push_back({v, c});
}
mx = max(mx, get(suff));
return 1;
}
suff.push_back({x, c});
if(same){
pref.push_back({x, c});
}
return 0;
}
asd operator +(asd x){
asd ans;
ans.suff = suff;
ans.same = same;
ans.pref = pref;
ans.mx = max(mx, x.mx);
for(auto y:x.pref){
if(ans.insert(y)){
break;
}
}
ans.mx = max(ans.mx, get(ans.suff));
if(!x.same) {
ans.same = 0;
ans.suff = x.suff;
}
ans.mx = max(ans.mx, get(ans.pref));
ans.mx = max(ans.mx, get(ans.suff));
return ans;
}
} t[400002];
int a[100020];
int n, m, k;
void build(int v,int tl,int tr){
if(tl == tr){
t[v] = asd(a[tl]);
}
else{
int mid = tl + tr >> 1;
build(v*2, tl, mid);
build(v*2+1, mid+1, tr);
t[v] = t[v*2] + t[v*2+1];
}
}
void upd(int v, int tl, int tr, int pos, int x){
if(tl == tr){
t[v] = asd(x);
}
else{
int mid = tl + tr >> 1;
if(pos <= mid){
upd(v*2, tl, mid, pos, x);
}
else{
upd(v*2+1, mid+1, tr, pos, x);
}
t[v] = t[v*2] + t[v*2+1];
}
}
asd get(int v, int tl, int tr, int l, int r){
if(tl > r || l > tr){
return t[0];
}
if(tl >= l && tr <= r){
return t[v];
}
int mid = tl + tr >> 1;
return get(v*2, tl, mid, l, r) + get(v*2+1, mid+1, tr, l, r);
}
void prepare_game(vector<int> A) {
n = A.size();
for(int i=0;i<n;i++){
a[i+1] = A[i];
}
build(1, 1, n);
}
int play_game(int l, int r) {
l++, r++;
return get(1, 1, n, l, r).mx;
}
void update_game(int p, int v) {
p++;
upd(1, 1, n, p, v);
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 5
Accepted
time: 79ms
memory: 544464kb
input:
10 2 2 1 2 2 2 2 1 2 2 10 1 0 2 1 0 9 1 0 5 1 2 4 1 0 9 1 2 7 1 3 7 1 7 9 1 1 3 1 0 2
output:
3 4 3 3 4 4 4 3 2 3
result:
ok 10 lines
Test #2:
score: 0
Accepted
time: 110ms
memory: 544536kb
input:
10 1 1 2 1 2 2 1 2 1 1 10 1 3 4 1 2 6 1 0 2 1 0 2 1 4 5 1 3 9 1 0 6 1 5 8 1 4 9 1 2 7
output:
2 3 3 3 3 3 3 2 3 3
result:
ok 10 lines
Test #3:
score: 0
Accepted
time: 95ms
memory: 544428kb
input:
10 1 2 1 2 2 2 2 1 2 2 10 1 0 2 1 1 2 1 0 1 1 1 1 1 8 9 1 3 5 1 4 7 1 1 9 1 3 6 1 6 7
output:
2 2 2 2 3 3 3 4 4 2
result:
ok 10 lines
Test #4:
score: 0
Accepted
time: 107ms
memory: 544500kb
input:
10 2 1 2 1 1 1 1 2 1 2 10 1 4 5 1 0 6 1 7 8 1 4 5 1 0 7 1 4 7 1 4 9 1 3 7 1 0 9 1 2 9
output:
2 3 2 2 4 3 3 3 4 4
result:
ok 10 lines
Test #5:
score: 0
Accepted
time: 67ms
memory: 545076kb
input:
10 1 1 1 1 1 1 1 1 1 1 10 2 2 1 2 7 1 2 5 1 2 6 1 2 8 1 1 4 6 2 6 1 2 1 1 1 1 4 2 5 1
output:
2 3
result:
ok 2 lines
Test #6:
score: 0
Accepted
time: 80ms
memory: 544412kb
input:
10 1 1 1 1 2 2 2 2 1 1 10 2 6 1 2 9 1 1 1 1 2 3 2 1 4 7 1 3 9 2 8 1 2 6 1 2 9 2 2 0 1
output:
1 3 3
result:
ok 3 lines
Test #7:
score: -5
Wrong Answer
time: 96ms
memory: 544468kb
input:
8 8 8 9 7 7 7 7 9 10 1 1 7 1 1 4 1 0 4 1 0 7 1 2 5 1 0 6 1 3 6 1 1 5 1 3 4 1 0 7
output:
11 9 10 11 9 10 9 9 8 11
result:
wrong answer 1st lines differ - expected: '10', found: '11'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 185ms
memory: 552740kb
input:
4000 1 1 1 1 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2...
output:
16 18 18 16 13 16 14 17 17 14 11 15 11 12 13 17 15 14 16 12 17 10 13 14 16 17 14 17 14 10 12 14 14 15 13 16 16 16 13 10 5 15 11 13 15 9 15 15 9 12 13 14 14 14 12 15 15 15 8 8 15 12 15 15 11 12 10 11 14 14 11 14 14 12 11 13 12 14 14 11 11 12 9 12 11 11 10 11 14 14 11 10 14 14 11 14 11 7 9 12 11 13 13...
result:
wrong answer 1st lines differ - expected: '11', found: '16'
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #3:
0%
Subtask #6:
score: 0
Wrong Answer
Test #69:
score: 0
Wrong Answer
time: 2008ms
memory: 744676kb
input:
100000 2 10 6 3 5 4 2 6 9 3 8 3 9 6 9 8 8 9 4 6 5 10 7 1 2 5 5 2 7 3 5 10 5 6 7 5 9 10 6 10 7 3 2 1 7 8 4 4 3 10 1 6 9 9 6 9 6 1 6 4 8 5 5 6 8 3 3 7 6 6 3 5 5 9 5 5 7 10 7 3 10 1 4 2 3 6 9 2 7 2 8 10 4 5 2 6 7 1 8 2 8 3 3 10 9 8 6 6 9 6 4 5 8 4 10 10 4 1 6 4 4 3 9 4 7 7 2 8 8 7 10 6 8 2 1 4 2 2 5 2 ...
output:
13 11 11 12 13 12 11 13 12 13 13 12 11 12 12 13 12 12 12 12 13 12 13 12 13 11 12 12 12 10 12 13 13 12 12 12 13 12 12 13 12 12 12 12 12 12 13 13 12 13 12 13 13 13 12 13 12 12 12 12 12 12 13 12 13 12 11 13 13 12 13 12 13 13 13 13 12 12 13 12 12 12 13 12 13 13 13 12 11 12 12 12 12 12 13 12 13 12 12 12 ...
result:
wrong answer 1st lines differ - expected: '12', found: '13'
Subtask #7:
score: 0
Skipped
Dependency #1:
0%