QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#190414 | #7043. Image Processing | ucup-team994 | TL | 998ms | 47380kb | C++14 | 2.0kb | 2023-09-28 20:38:29 | 2023-09-28 20:38:29 |
Judging History
answer
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
const int INF=2147483647;
const int N=1e6+5;
int n,K,last_ans,head(0),now_dp,now_diff,a[N],dp[N],pre_dp,pre_diff;
multiset<int> S_of_dp,S_of_diff;
int max(int a,int b) {
return a>=b?a:b;
}
int min(int a,int b) {
return a<=b?a:b;
}
void add_dp(int x) {
S_of_dp.insert(x);
now_dp=*S_of_dp.begin();
}
void del_dp(int x) {
S_of_dp.erase(S_of_dp.find(x));
now_dp=*S_of_dp.begin();
}
void add_diff(int x) {
S_of_diff.insert(x);
now_diff=(*S_of_diff.rbegin())-(*S_of_diff.begin());
}
void del_diff(int x) {
S_of_diff.erase(S_of_diff.find(x));
now_diff=(*S_of_diff.rbegin())-(*S_of_diff.begin());
}
void get_pre_dp_diff(int pos) {
if(pos!=0) {
pre_dp=min(now_dp,dp[pos-1]);
pre_diff=max(*S_of_diff.rbegin(),a[pos])-min(*S_of_diff.begin(),a[pos]);
} else {
pre_dp=pre_diff=INF;
}
return;
}
void put(int x) {
if(x>9)put(x/10);
putchar((char)(x%10+'0'));
}
int read() {
int x(0);
char ch(getchar());
while(ch>'9'||ch<'0')ch=getchar();
while(ch<='9'&&ch>='0') {
x=x*10+ch-'0';
ch=getchar();
}
return x;
}
int main() {
// freopen("test.in","r",stdin);
// freopen("test.out","w",stdout);
n=read();
K=read();
for(int i=1; i<=n; i++) {
a[i]=read();
a[i]^=last_ans;
add_diff(a[i]);
if(i>=K) {
add_dp(dp[i-K]);
// if(i==21)cout<<S_of_dp.count(dp[i-K])<<'\n';
while(now_diff>=now_dp&&head<i-K) {
del_diff(a[head+1]);
del_dp(dp[head]);
head++;
}
get_pre_dp_diff(head);
last_ans=dp[i]=min(max(now_dp,now_diff),max(pre_dp,pre_diff));
// if(max(now_dp,now_diff)<=max(pre_dp,pre_diff))cout<<head<<" ";
// else cout<<head-1<<" ";
} else {
dp[i]=INF;
last_ans=0;
}
put(last_ans);
putchar('\n');
}
return 0;
}
/*
21 7
740760744 128949015 864430306 803157027 867410355 348411907 788815333 62537628 989888355 897434632 893725957 385915358 116671606 91645858 585889989 81062060 177182250 543069056 107482294 981936827 433021299
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5416kb
input:
5 2 50 110 190 120 34
output:
0 60 80 90 80
result:
ok 5 number(s): "0 60 80 90 80"
Test #2:
score: 0
Accepted
time: 329ms
memory: 11504kb
input:
1000000 7 740760744 128949015 864430306 803157027 867410355 348411907 788815333 62537628 989888355 897434632 893725957 385915358 116671606 91645858 585889989 81062060 177182250 543069056 107482294 981936827 433021299 764779421 730485811 37353026 476269126 318260875 564753383 841579792 652031776 3016...
output:
0 0 0 0 0 0 738461340 738461340 738461340 738461340 738461340 861209643 861209643 738461340 739549417 739549417 739549417 783969241 783969241 783969241 738461340 904097193 904097193 910753514 910753514 910753514 910753514 910753514 904097193 904097193 904097193 904097193 904097193 904097193 90409719...
result:
ok 1000000 numbers
Test #3:
score: 0
Accepted
time: 374ms
memory: 12164kb
input:
1000000 106 718106353 957103229 178679497 30122152 539392262 967694986 411843264 878332932 304891280 49993165 575798961 112319481 929328366 408264344 69150964 860984775 852441333 611859467 307742908 777689983 835915923 680677321 283125322 870857035 73680192 903946994 345887196 671045189 390601447 92...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 973002280 973002280 973002280 973002280 973002280 973731513 973731513 973731513 973731513 ...
result:
ok 1000000 numbers
Test #4:
score: 0
Accepted
time: 437ms
memory: 15208kb
input:
1000000 638 192463945 702134958 345542618 669865830 85855398 439488356 311123607 983422443 824130032 482375875 82888112 834016258 434451960 842325416 278600378 970131765 191089971 973830613 676858689 16912555 889301644 195308390 8838132 65590862 91160693 10485363 565917834 867947180 403081242 995642...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 1000000 numbers
Test #5:
score: 0
Accepted
time: 548ms
memory: 19764kb
input:
1000000 4419 766757907 691258997 943689588 724926794 873612124 655942731 622247010 127393979 566689614 916397853 129170439 351371578 395010700 362176313 144517148 334931535 997357717 866472973 141659563 230674896 754534513 915060959 784926145 24412372 17940633 506638086 568637474 674497801 972536484...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 1000000 numbers
Test #6:
score: 0
Accepted
time: 998ms
memory: 41344kb
input:
1000000 15252 482549745 234451363 379198395 186404152 746970639 99618958 954628472 864867575 609040514 853026700 88647190 400589742 756951366 226001929 346217977 249948293 755539806 996608570 767720589 187525639 705337860 968784962 806623701 413357199 781068200 120489841 202517850 986199359 63965896...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 1000000 numbers
Test #7:
score: 0
Accepted
time: 778ms
memory: 47380kb
input:
1000000 90363 331128761 509207949 860935618 851737770 12782945 265991521 159033465 230755590 575795471 302069501 735319593 397331166 215596429 944601335 38654297 283607457 871187280 284970611 144750064 165814817 565050266 902545684 915339326 600166122 608673261 386967346 379027093 317636179 18468832...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 1000000 numbers
Test #8:
score: -100
Time Limit Exceeded
input:
1000000 292559 549452146 479848976 745070445 686754013 198234287 555646589 3702198 545375873 109081524 521400181 997751872 59430741 554115035 141720157 286973665 832701708 71078753 80672658 127375045 490357270 559098464 237998960 960880460 786418982 915726177 377843147 691025264 505678474 566734492 ...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...