zoj 3398 Warden

zoj 3398 Warden,第1张

zoj 3398 Warden
#include <cstdio>#include <cstring>#include <cstdlib>#include <cassert>#include <algorithm>using namespace std;static int dummy;bool a[31][31][31][31][8];struct State {static int varchmage, vwarden;short sarchmage;short swarden;short mana;short hp;short poison;void gao(int timespan, bool prepare = false) {if (poison <= timespan) {sarchmage -= poison + varchmage * (timespan - poison);poison = 0;} else {sarchmage -= timespan;poison -= timespan;}if (!prepare) {swarden -= vwarden * timespan;}if (swarden < sarchmage) {swarden = sarchmage;}}};int State::varchmage;int State::vwarden;struct FanOfKnives {int t, p, r, h;State gao(State s) const {s.gao(t, true);if (s.swarden - s.sarchmage > r) {s.sarchmage = -1;return s;}s.mana -= p;s.hp -= h;return s;}} fok;struct ShadowStrike {int t, p, r, h, T;State gao(State s) const {s.gao(t, true);if (s.swarden - s.sarchmage > r) {s.sarchmage = -1;return s;}s.mana -= p;s.hp -= h;s.poison = T;return s;}} ss;struct Blink {static const int t = 1;int p, r;State gao(State s) const {s.gao(t, true);s.mana -= p;s.swarden -= r;return s;}} blink;int dp[64];void gao(const State& s) {if (s.sarchmage <= 0 || s.mana < 0) {return;} else if (s.hp <= 0) {throw 1;} else if (s.sarchmage > s.swarden) {if (dp[s.mana] >= s.hp) {throw 1;}} else {if (a[s.sarchmage][s.swarden][s.hp][s.mana][s.poison]) {return;} else {a[s.sarchmage][s.swarden][s.hp][s.mana][s.poison] = true;}gao(blink.gao(s));gao(fok.gao(s));gao(ss.gao(s));State ss = s;ss.gao(1);gao(ss);}}int main() {int re;State init;dummy = scanf("%d", &re);for (int ri = 1; ri <= re; ++ri) {dummy = scanf("%hd%hd%d%d%hd%hd", &init.sarchmage, &init.swarden, &State::varchmage, &State::vwarden, &init.mana, &init.hp);init.poison = 0;dummy = scanf("%d%d%d%d", &fok.t, &fok.p, &fok.r, &fok.h);dummy = scanf("%d%d%d%d%d", &ss.t, &ss.p, &ss.r, &ss.h, &ss.T);dummy = scanf("%d%d", &blink.p, &blink.r);fill(dp, dp + 64, 0);for (int i = fok.p; i < 64; ++i) {dp[i] = max(dp[i], dp[i - fok.p] + fok.h);}for (int i = ss.p; i < 64; ++i) {dp[i] = max(dp[i], dp[i - ss.p] + ss.h);}memset(a, 0, sizeof(a));try {gao(init);puts("no");} catch (...) {puts("yes");}}return 0;}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4942892.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-13
下一篇 2022-11-13

发表评论

登录后才能评论

评论列表(0条)

保存