QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#622218#5146. SkillsyanshanjiahongWA 59ms81360kbC++141.9kb2024-10-08 20:20:202024-10-08 20:20:21

Judging History

你现在查看的是最新测评结果

  • [2024-10-08 20:20:21]
  • 评测
  • 测评结果:WA
  • 用时:59ms
  • 内存:81360kb
  • [2024-10-08 20:20:20]
  • 提交

answer

#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define ls(x) (x<<1)
#define rs(x) ((x<<1)|1)
#define mp make_pair
#define sec second
#define fir first
#define pii pair<int,int>
#define lowbit(i) i&-i
#define int long long
#define double long double
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1005,M=1e6+5,S=(1<<15)+5,inf=(ll)1e18+7,mo=998244353;
const double eps=1e-8;
void read(int &p){
	int x=0,w=1;
	char ch=0;
	while(!isdigit(ch)){
		if(ch=='-')w=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+ch-'0';
		ch=getchar();
	}
	p=x*w;
}
int T;
int n,a[N][3];
int f[N][105][105][3];
void getmax(int &x,int v){
    x=max(x,v);
}
void solve(){
    read(n);
    int maxn=0;
    rep(i,1,n){
        rep(j,0,2)
            read(a[i][j]),maxn=max(maxn,a[i][j]);
    }
    int upp=ceil(sqrt(maxn));
    rep(i,0,n){
        rep(j,0,upp){
            rep(k,0,upp){
                rep(l,0,2)
                    f[i][j][k][l]=-inf;
            }
        }
    }
    f[0][0][0][1]=0;
    rep(i,0,n-1){
        rep(j,0,upp){
            rep(k,0,upp){
                rep(l,0,2){
                    if(f[i][j][k][l]<0)continue;
                    int trans[3];
                    trans[l]=(!i?0:1),trans[(l+1)%3]=j,trans[(l+2)%3]=k;
                    if(j)trans[(l+1)%3]++;
                    if(k)trans[(l+2)%3]++;//j,k 是 0 说明这个还没被选过
                    rep(x,0,2)
                        getmax(f[i+1][trans[(x+1)%3]][trans[(x+2)%3]][x],f[i][j][k][l]+a[i+1][x]-trans[(x+1)%3]-trans[(x+2)%3]);
                }
            }
        }
    }
    int ans=0;
    rep(j,0,upp){
        rep(k,0,upp){
            rep(l,0,2)
                ans=max(ans,f[n][j][k][l]);
        }
    }
    printf("%lld\n",ans);
}
signed main(){
    read(T);
    while(T--)
        solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5976kb

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: 0
Accepted
time: 35ms
memory: 56152kb

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:

1505431

result:

ok 1 number(s): "1505431"

Test #3:

score: 0
Accepted
time: 36ms
memory: 57612kb

input:

1
200
7577 2771 7429
8435 7489 1440
1929 8819 818
7849 8462 8761
3344 5938 3673
9434 8897 6486
4668 636 8139
4777 3305 4238
4221 3326 639
3879 7469 1590
6370 9514 4307
6243 3301 8122
4967 184 9327
6142 1710 399
6814 9296 6270
5663 3564 5442
8315 1295 869
2635 7975 4837
9613 9439 4012
6660 1861 368
8...

output:

1497632

result:

ok 1 number(s): "1497632"

Test #4:

score: -100
Wrong Answer
time: 59ms
memory: 81360kb

input:

1
300
0 10000 0
0 10000 0
0 10000 0
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
1000...

output:

2975224

result:

wrong answer 1st numbers differ - expected: '2975228', found: '2975224'