ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#196355 | #2461. 序列函数 | hsfzbzjr | 100 | 573ms | 12076kb | C++11 | 1.5kb | 2023-10-22 11:47:27 | 2023-10-22 12:08:05 |
answer
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int N=1e3+10;
int n,nQ;
ull a[N];
namespace subtask1{
int C[60][60];
void precompute(){
C[0][0]=1;
for(int i=1;i<=50;i++){
C[i][0]=1;
for(int j=1;j<i;j++)C[i][j]=C[i-1][j-1]^C[i-1][j];
C[i][i]=1;
}
}
void solve(){
precompute();
int ql,qr;
while(nQ--){
ull ans=0,mx=0;
scanf("%d %d",&ql,&qr);
for(int l=ql;l<=qr;l++)
for(int r=l;r<=qr;r++){
mx=0;
int len=r-l+1;
for(int i=l;i<=r;i++){
mx=mx^(C[len-1][i-l]*a[i]);
}
ans=max(ans,mx);
}
printf("%llu\n",ans);
}
}
}
namespace subtask2{
int C[N][N];
ull dp[N][N];
ull calc(int l,int r){
ull ret=0;
int len=r-l+1;
for(int i=l;i<=r;i++){
ret=ret^(C[len-1][i-l]*a[i]);
}
return ret;
}
void precompute(){
C[0][0]=1;
for(int i=1;i<=n;i++){
C[i][0]=1;
for(int j=1;j<i;j++)C[i][j]=C[i-1][j-1]^C[i-1][j];
C[i][i]=1;
}
for(int i=1;i<=n;i++)dp[i][i]=a[i];
for(int len=2;len<=n;len++)
for(int l=1;l+len-1<=n;l++){
int r=l+len-1;
dp[l][r]=max(dp[l+1][r],dp[l][r-1]);
dp[l][r]=max(dp[l][r],calc(l,r));
}
}
void solve(){
precompute();
int ql,qr;
while(nQ--){
scanf("%d %d",&ql,&qr);
printf("%llu\n",dp[ql][qr]);
}
}
}
int main(){
scanf("%d %d",&n,&nQ);
for(int i=1;i<=n;i++)scanf("%llu",&a[i]);
if(n<=50&&nQ<=50)
subtask1::solve();
else
subtask2::solve();
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1216kb
input:
42 49 1783202742 1774487945 518236540 362135926 386007499 684539866 40822510 1761379686 1956018045 1...
output:
2143704053 2015166884 2144556949 1506308040 2142362987 2146632215 2146632215 2146632215 2068269397 2...
result:
ok 49 lines
Test #2:
score: 10
Accepted
time: 0ms
memory: 1212kb
input:
42 33 807451392 1594697903 822298754 791804335 186109850 378511438 522423033 425169948 1522110804 89...
output:
2122736149 2145707346 2129880922 2050476931 2077925883 2145056931 2145707346 2040286149 2140052661 2...
result:
ok 33 lines
Test #3:
score: 10
Accepted
time: 0ms
memory: 1212kb
input:
50 50 549358834089146323 8281292981227534763 207444435364729985 15702617371830656254 100065109098336...
output:
18349122426892637836 18424642816185963297 18424642816185963297 18424642816185963297 1834912242689263...
result:
ok 50 lines
Test #4:
score: 10
Accepted
time: 0ms
memory: 3064kb
input:
211 288 1541777479237755621 7380930312367719955 18108376653806178106 5478389836749642688 79169076237...
output:
18441496847620896589 18441496847620896589 18445094639670047188 18441496847620896589 1844576586180516...
result:
ok 288 lines
Test #5:
score: 10
Accepted
time: 3ms
memory: 3952kb
input:
300 300 13173047521501495255 10953077477026411483 9510832264046195437 17718064857871536690 697815050...
output:
18446557541718203738 18423433381304363788 18446557541718203738 18104404130056939072 1839536653439987...
result:
ok 300 lines
Test #6:
score: 10
Accepted
time: 48ms
memory: 8572kb
input:
704 823 10383085696588517611 15289910603977389948 8677788864453886692 13752832787548255691 147484473...
output:
18446630762333876316 18423909590519364175 18445223070107393984 18446565292956783316 1844577449320985...
result:
ok 823 lines
Test #7:
score: 10
Accepted
time: 151ms
memory: 11884kb
input:
984 96949 9963157970145598319 14580206340515272781 7491124242731166719 15710061550121502290 17496952...
output:
18446600579277745879 18350702067697472412 18446733764113276192 18446516668583026953 1844325333828644...
result:
ok 96949 lines
Test #8:
score: 10
Accepted
time: 107ms
memory: 10632kb
input:
878 82408 8940297609593388475 5462297751515208042 14733942868464620325 5612045775407545021 647690935...
output:
18446702727635691275 18446699238696255412 18446702727635691275 18446699238696255412 1844635297729416...
result:
ok 82408 lines
Test #9:
score: 10
Accepted
time: 91ms
memory: 9380kb
input:
772 72983 15460039955329036647 7155312777175822862 17006627873007892975 4747353407166593171 14231318...
output:
18445806169258170293 18446480690417164748 18294830692476358701 18446152273808621765 1844580616925817...
result:
ok 72983 lines
Test #10:
score: 10
Accepted
time: 173ms
memory: 12076kb
input:
1000 100000 2221357305344673673 8355251918668090901 490161488299128800 7629701439793791725 513258466...
output:
18442923800112303923 18443578727890069360 18446667346999006141 18398745104155425750 1825524423658037...
result:
ok 100000 lines
Extra Test:
score: 0
Extra Test Passed