QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#786467#5146. SkillsAlicXWA 98ms6760kbC++204.0kb2024-11-26 21:39:352024-11-26 21:39:35

Judging History

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

  • [2024-11-26 21:39:35]
  • 评测
  • 测评结果:WA
  • 用时:98ms
  • 内存:6760kb
  • [2024-11-26 21:39:35]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define re register
#define il inline
#define pii pair<int,int>
#define x first
#define y second
#define gc getchar()
#define rd read()
#define debug() puts("------------")

namespace yzqwq{
    il int read(){
        int x=0,f=1;char ch=gc;
        while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=gc;}
        while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=gc;
        return x*f;
    }
    il int qmi(int a,int b,int p){
        int ans=1;
        while(b){
            if(b&1) ans=ans*a%p;
            a=a*a%p,b>>=1;
        }
        return ans;
    }
    il int gcd(int a,int b){
        if(!b) return a;
        return gcd(b,a%b);
    }
    il int lcm(int a,int b){
        return a/gcd(a,b)*b;
    }
    il void exgcd(int a,int b,int &x,int &y){
        if(!b) return x=1,y=0,void(0);
        exgcd(b,a%b,x,y);
        int t=x;
        x=y,y=t-a/b*x;
        return ;
    }
    il int F(int n,int a,int b,int c){
        //sum{|_ (ai+b)/c _| i:0~n}
        if(!n) return b/c;
        if(!a) return (n+1)*(b/c);
        if(a>=c||b>=c){
            int x=a/b,y=b/c;
            return n*(n+1)/2*x+(n+1)*y+F(n,a%c,b%c,c);
        }
        int m=(a*n+b)/c;
        return n*m+F(m-1,c,c-b+1,a);
    }
    struct lb{
        int d[64];
        il void print(){
            for(re int i=0;i<63;++i)
            if(d[i]) printf("%lld:%lld\n",i,d[i]);
            return ;
        }
        lb(){memset(d,0,sizeof(d));}
        il void operator +=(int x){
            for(re int i=62;i>=0;--i){
                if(!(x&(1ll<<i))) continue;
                if(d[i]) x^=d[i];
                else return d[i]=x,void(0);
            }
            return ;
        }
        int& operator [](int x){
            return d[x];
        }
        il void operator +=(lb &x){
            for(re int i=62;i>=0;--i)
            if(x[i]) *this+=x[i];
            return ;
        }
        il friend lb operator +(lb &x,lb &y){
            lb z=x;
            for(re int i=62;i>=0;--i)
            if(y[i]) z+=y[i];
            return z;
        }
        il int Max_calc(){
            int ans=0;
            for(re int i=62;i>=0;--i)
            if((ans^d[i])>ans) ans^=d[i];
            return ans;
        }
    };
    mt19937 rnd(time(0));
}
using namespace yzqwq;

const int N=30005,M=250;
int n,w,a[3][N];
int f[2][3][M][M];

il void solve(){
	n=rd,w=0;
	for(re int i=1;i<=n;++i)
	for(re int j=0;j<=2;++j) a[j][i]=rd;
	for(re int j=0;j<=2;++j)
	for(re int x=0;x< M;++x)
	for(re int y=0;y< M;++y) f[w][j][x][y]=-1e18;
	f[w][0][0][0]=f[w][1][0][0]=f[w][2][0][0]=0;
	for(re int i=1;i<=n;++i){
		w^=1;
		for(re int j=0;j<=2;++j)
		for(re int x=0;x< M;++x)
		for(re int y=0;y< M;++y) f[w][j][x][y]=-1e18;		
		for(re int j=0;j<=2;++j)
		for(re int x=0;x< M;++x)
		for(re int y=0;y< M;++y){
			int x_=x+1,y_=y+1;
			if(!x) x_=0;
			if(!y) y_=0;
			if(j==0){
				f[w][0][x_][y_]=max(f[w][0][x_][y_],f[w^1][j][x][y]-x_-y_+a[0][i]);
				f[w][1][1 ][y_]=max(f[w][1][1 ][y_],f[w^1][j][x][y]-1 -y_+a[1][i]);
				f[w][2][x_][1 ]=max(f[w][2][x_][1 ],f[w^1][j][x][y]-x_-1 +a[2][i]);
			}
			else if(j==1){
				f[w][0][1 ][y_]=max(f[w][0][1 ][y_],f[w^1][j][x][y]-1 -y_+a[0][i]);
				f[w][1][x_][y_]=max(f[w][1][x_][y_],f[w^1][j][x][y]-x_-y_+a[1][i]);
				f[w][2][x_][1 ]=max(f[w][2][x_][1 ],f[w^1][j][x][y]-x_-1 +a[2][i]);				
			}
			else if(j==2){
				f[w][0][1 ][y_]=max(f[w][0][1 ][y_],f[w^1][j][x][y]-1 -y_+a[0][i]);
				f[w][1][x_][1 ]=max(f[w][1][x_][1 ],f[w^1][j][x][y]-x_-1 +a[1][i]);
				f[w][2][x_][y_]=max(f[w][2][x_][y_],f[w^1][j][x][y]-x_-y_+a[2][i]);				
			}
		}
	}
	int Max=0;
	for(re int j=0;j<=2;++j)
	for(re int x=0;x< M;++x)
	for(re int y=0;y< M;++y) Max=max(Max,f[w][j][x][y]);
	printf("%lld\n",Max);
    return ;
}

signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
    int t=rd;while(t--)
    solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 5ms
memory: 6760kb

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: 98ms
memory: 6740kb

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:

1505393

result:

wrong answer 1st numbers differ - expected: '1505431', found: '1505393'