CH5E01[NOIP2010] 乌龟棋[暴力]
众所周知,由于这个人太菜了,所以她又来切上古水题了。
显然最多$40^4$种状态,暴力跑出可以拼出多少种状态,然后按序号从小到大对应的状态瞎转移即可。
我知道我想繁了,但是不想改了,因为思路一出来,没有再想直接无脑秒掉的,所以您可以大呼本人是菜鸡。
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<queue> #include<vector> #define dbg(x) cerr<<#x<<" = "<<x<<endl #define _dbg(x,y) cerr<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl using namespace std; typedef long long ll; template<typename T>inline char MIN(T&A,T B){return A>B?A=B,1:0;} template<typename T>inline char MAX(T&A,T B){return A<B?A=B,1:0;} template<typename T>inline T _min(T A,T B){return A<B?A:B;} template<typename T>inline T _max(T A,T B){return A>B?A:B;} template<typename T>inline T read(T&x){ x=0;int f=0;char c;while(!isdigit(c=getchar()))if(c=='-')f=1; while(isdigit(c))x=x*10+(c&15),c=getchar();return f?x=-x:x; } const int N=350+5; struct thxorz{ int x,y,z; thxorz(int x=0,int y=0,int z=0):x(x),y(y),z(z){} }; vector<thxorz> card[N]; int a[N],f[N][42][42][42],cnt[5]; int n,m,x,y,z; int main(){//freopen("test.in","r",stdin);//freopen("test.out","w",stdout); read(n),read(m); for(register int i=1;i<=n;++i)read(a[i]); for(register int i=1;i<=m;++i)++cnt[read(x)]; for(register int i=0;i<=cnt[1];++i) for(register int j=0;j<=cnt[2];++j) for(register int k=0;k<=cnt[3];++k) for(register int l=0;l<=cnt[4];++l) card[i+(j<<1)+(k<<1)+k+(l<<2)+1].push_back(thxorz(j,k,l)); f[1][0][0][0]=a[1];card[1].push_back(thxorz(0,0,0)); for(register int i=1;i<n;++i)if(!card[i].empty()){ for(register int j=0;j<(int)card[i].size();++j){ x=card[i][j].x,y=card[i][j].y,z=card[i][j].z; MAX(f[i+1][x][y][z],f[i][x][y][z]+a[i+1]); MAX(f[i+2][x+1][y][z],f[i][x][y][z]+a[i+2]); MAX(f[i+3][x][y+1][z],f[i][x][y][z]+a[i+3]); MAX(f[i+4][x][y][z+1],f[i][x][y][z]+a[i+4]); } } printf("%d\n",f[n][cnt[2]][cnt[3]][cnt[4]]); return 0; }