QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#658740 | #5146. Skills | SouthernB# | WA | 1ms | 3592kb | C++14 | 1.7kb | 2024-10-19 17:30:36 | 2024-10-19 17:30:40 |
Judging History
answer
#include<bits/stdc++.h>
using std::cin;
using std::cout;
const int F=1e9;
inline void mmx(int&x,int y){x=std::max(x,y);}
const int N=1000,M=3,S=8;//
const int ar[]={0,1,2,4,3,5,6,7};
int n,va[N+5][3];
int cp[S][3][M+5][M+5],f[S][3][M+5][M+5];
int ans;
inline int lm(int s,int j,int o){
if(s>>((j+o)%3)&1)return M;
else return 0;
}
inline void fil(int a[][3][M+5][M+5],int x){
for(int i=1;i<S;++i)
for(int j=0;j<3;++j)
for(int k=0;k<=lm(i,j,1);++k)
for(int l=0;l<=lm(i,j,2);++l)
a[i][j][k][l]=x;
}
inline void upd(int x){
fil(cp,-F);
for(int i=1;i<S;++i){
int s=ar[i];
for(int j=0;j<3;++j)if(s>>j&1)
for(int k=0;k<=lm(s,j,1);++k)
for(int l=0;l<=lm(s,j,2);++l){
mmx(ans,f[s][j][k][l]);
for(int t=1;t<S;++t)if((s&t)==t)
for(int o=0;o<3;++o)if(t>>o&1){
int t0=t>>j&1,t1=t>>(j+1)%3&1?1:0,t2=t>>(j+2)%3&1?1:0;
if(o==j)mmx(cp[t][o][k+t1][l+t2],f[s][j][k][l]+va[x][o]-t1*(k+1)-t2*(l+1));
else if(o==(j+1)%3)mmx(cp[t][o][l+t2][t0],f[s][j][k][l]+va[x][o]-t2*(l+1)-t0);
else mmx(cp[t][o][t0][k+t1],f[s][j][k][l]+va[x][o]-t1*(k+1)-t0);
}
}
}
for(int i=1;i<S;++i)
for(int j=0;j<3;++j)
for(int k=0;k<=lm(i,j,1);++k)
for(int l=0;l<=lm(i,j,2);++l)
f[i][j][k][l]=cp[i][j][k][l];
}
inline void solve(){
cin>>n;
for(int i=1;i<=n;++i)
cin>>va[i][0]>>va[i][1]>>va[i][2];
fil(f,-F),f[7][0][0][0]=0;
for(int i=n;i>=0;--i)
upd(i);
cout<<ans<<'\n';
}
inline void clear(){
fil(f,0),fil(cp,0);
ans=0;
}
int main(){
std::ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
int t;
cin>>t;
while(t--){
solve();
clear();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3544kb
input:
2 3 1 1 10 1 10 1 10 1 1 5 1 2 3 6 5 4 7 8 9 12 11 10 13 14 15
output:
26 41
result:
ok 2 number(s): "26 41"
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3592kb
input:
1 200 6219 3608 2383 1139 2158 8611 6721 8216 8887 8736 6707 9755 7210 248 167 3849 276 8050 971 5062 1914 8290 1562 6017 8993 7990 3460 6323 6099 757 7652 4740 6117 6560 4206 180 3705 8906 5752 9619 8939 9696 793 6680 1777 384 3606 8772 9258 3906 709 4396 5083 6614 6057 4410 3132 8596 825 7437 6098...
output:
1395781
result:
wrong answer 1st numbers differ - expected: '1505431', found: '1395781'