| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
效果较好的剪枝/*
记录一下最大L[i]用来剪枝
*/
#include<iostream>
using namespace std;
#define maxn 12
#define maxhp 105
#define maxmp 55
int n,L,Hp,Mp,Mhp,Mn,v,dh,l[maxn],sol[maxhp][maxmp][maxhp][maxn];
bool rec[maxhp][maxmp][maxhp][maxn],done[maxhp][maxmp][maxhp][maxn];
void Init() {
scanf("%d%d%d",&n,&Hp,&Mp);
scanf("%d%d%d",&Mhp,&Mn,&v);
scanf("%d",&dh);
L=0;
for (int i=1; i<=n; i++) {
scanf("%d",&l[i]);
L>?=l[i];
}
}
inline void Monster(int& hp,int& mp,int& mhp,int& pos) {
if (mhp<=0) return;
int d=min(v,pos-1);
pos-=d;
if (pos==1) {
int sum=mhp/Mhp;
if (mhp%Mhp) sum++;
hp-=sum;
}
}
inline bool F(int hp,int mp,int mhp,int pos) {
if (hp<=0) return false;
if (mhp<=0) return true;
if (!mp) return false;
if (mp*L<mhp) return false;//不写这几个字就TLE
if (done[hp][mp][mhp][pos]) return rec[hp][mp][mhp][pos];
done[hp][mp][mhp][pos]=true;
int a,b,c,d;
a=hp,b=mp,c=mhp,d=pos;
c-=l[d],b--;
Monster(a,b,c,d);
if (F(a,b,c,d)) {
sol[hp][mp][mhp][pos]=-1;
rec[hp][mp][mhp][pos]=true;
return true;
}
a=hp,b=mp,c=mhp,d=pos;
a+=dh,a<?=Hp,b--;
Monster(a,b,c,d);
if (F(a,b,c,d)) {
sol[hp][mp][mhp][pos]=-2;
rec[hp][mp][mhp][pos]=true;
return true;
}
for (int i=1; i<=n; i++) if (i!=pos) {
a=hp,b=mp-1,c=mhp,d=i;
Monster(a,b,c,d);
if (F(a,b,c,d)) {
sol[hp][mp][mhp][pos]=i;//这里一开始写成了d
rec[hp][mp][mhp][pos]=true;
return true;
}
}
return false;
}
inline void Print(int hp,int mp,int mhp,int pos) {
int flag=sol[hp][mp][mhp][pos];
if (flag==-1) {
puts("L");
mhp-=l[pos];
} else if (flag==-2) {
puts("H");
hp+=dh;
hp<?=Hp;
} else {
printf("T %d\n",flag);
pos=flag;
}
mp--;
if (mhp<=0) return;
Monster(hp,mp,mhp,pos);
Print(hp,mp,mhp,pos);
}
int main() {
Init();
if (F(Hp,Mp,Mhp*Mn,n)) {
puts("VICTORIOUS");
Print(Hp,Mp,Mhp*Mn,n);
}
else puts("DEFEATED");
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator