QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#115323 | #6649. 那些脑海里最珍贵的 | applese | WA | 1ms | 3784kb | C++14 | 10.0kb | 2023-06-25 17:13:15 | 2023-06-25 17:13:16 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define weak 0
#define average 1
#define strong 2
const double eps = 1e-7;
const int pid[7] = {0, 5, 3, 1, 2, 4, 6}, pos[7] = {0, 3, 4, 2, 5, 1, 6};
const char team[2][6] = {"South", "North"}, type[3][10] = {"Weak", "Average", "Strong"};
const double skl[3][6] = {{0, 0.1, 0.12, 0.15, 0.17, 0.20}, {0, 0.06, 0.07, 0.08, 0.09, 0.10}, {0, 2.1, 2.17, 2.24, 2.32, 2.4}};
double ty[3][3], dir[6] = {1.25, 1.00, 0.75, 0.00, 0.75, 1.00};
struct Soldier {
int type, lv, maxhp, nowhp, skilllv, passivelv, wtype, rd;
double atk, def, watk, skleff, dechp;
void Read() {
char str[10], wstr[10];
scanf("%s Lv=%d maxhp=%d atk=%lf def=%lf skillLv=%d passivesklLv=%d %s weaponatk=%lf", str + 1, &lv, &maxhp, &atk, &def, &skilllv, &passivelv, wstr + 1, &watk);
if(str[1] == 'W')
type = weak;
if(str[1] == 'A')
type = average;
if(str[1] == 'S')
type = strong;
if(wstr[1] == 'B')
wtype = 0;
if(wstr[1] == 'G')
wtype = 1;
if(wstr[1] == 'M')
wtype = 2;
nowhp = maxhp;
skleff = 1;
dechp = 0;
rd = 0;
}
}player[2][7];
int Alive(int p, int id) {
return player[p][id].nowhp > 0;
}
int AllDead(int p) {
for(int i = 1; i <= 6; ++ i)
if(Alive(p, i))
return 0;
return 1;
}
void Passive(int p) {
double eff = 0;
for(int i = 1; i <= 6; ++ i) {
if(Alive(p, i) && player[p][i].type == weak && player[p][i].passivelv) {
eff += player[p][i].passivelv * 0.003 + 0.01;
}
}
if(eff) {
eff = min(eff, 0.05);
for(int i = 1; i <= 6; ++ i) {
if(Alive(p, i) && player[p][i].nowhp < player[p][i].maxhp) {
int inc = floor(player[p][i].maxhp * eff + eps);
int x = min(player[p][i].maxhp, player[p][i].nowhp + inc);
printf("%s %d recovered +%d hp -> %d/%d\n", team[p], i, inc, x, player[p][i].maxhp);
player[p][i].nowhp = x;
}
}
}
}
int n[2], q, pre[2];
double CalcDef(int p, int id) {
double d = player[p][id].def, x = 0;
for(int i = 1; i <= 6; ++ i) {
if(Alive(p, i) && player[p][i].type == average) {
x += player[p][i].passivelv / 100.0;
}
}
x = min(x, 0.1);
x += 1;
// cerr << "Def " << player[p][id].def << " Defeff = " << x << endl;
return d * x;
}
double CalcAtk(int p, int id, double spe = 1.0) {
double a = player[p][id].atk * player[p][id].watk * spe * player[p][id].skleff, x = 0;
for(int i = 1; i <= 6; ++ i) {
if(Alive(p, i) && player[p][i].type == strong) {
x += player[p][i].passivelv / 100.0;
}
}
// cerr << x << endl;
x = min(x, 0.1);
x += 1;
// cerr << "Atk = " << a << " " << player[p][id].atk << " " << player[p][id].watk << " " << spe << " " << player[p][id].skleff << " Atk Passive = " << x << endl;
return a * x;
}
char tmp[105];
int Parse() {
scanf("%s", tmp + 1);
int len = strlen(tmp + 1);
assert(isdigit(tmp[len]));
return tmp[len] - '0';
}
void Basic(int p, int id) {
int tar = 0, atkp = 0, dgp = 0;
tar = Parse(), atkp = Parse(), dgp = Parse();
double d = CalcDef(p ^ 1, tar);
double a = CalcAtk(p, id);
a *= ty[player[p][id].type][player[p ^ 1][tar].type] * dir[(atkp - dgp + 6) % 6];
int dec = floor(a / d + eps), rem = max(0, player[p ^ 1][tar].nowhp - dec);
// cerr << a << " " << d << " " << dec << " " << rem << endl;
printf("%s %d took %d damage from %s %d -> %d/%d\n", team[p ^ 1], tar, dec, team[p], id, rem, player[p ^ 1][tar].maxhp);
player[p ^ 1][tar].nowhp = rem;
player[p][id].skleff = 1;
}
void Special(int p, int id) {
int tar = 0, atkp = 0, dgp = 0;
tar = Parse(), atkp = Parse(), dgp = Parse();
if(player[p][id].wtype == 0) { // B
double d = CalcDef(p ^ 1, tar);
double a = CalcAtk(p, id, 1.25);
a *= ty[player[p][id].type][player[p ^ 1][tar].type] * dir[(atkp - dgp + 6) % 6];
int dec = floor(a / d + eps), rem = max(0, player[p ^ 1][tar].nowhp - dec);
printf("%s %d took %d damage from %s %d -> %d/%d\n", team[p ^ 1], tar, dec, team[p], id, rem, player[p ^ 1][tar].maxhp);
player[p ^ 1][tar].nowhp = rem;
player[p][id].skleff = 1;
}
if(player[p][id].wtype == 1) { // G
int x = tar, y = 0, z = 0, c = 1;
for(int i = pos[tar] - 1; i > 0; -- i) {
if(Alive(p ^ 1, pid[i])) {
y = pid[i];
++ c;
break;
}
}
for(int i = pos[tar] + 1; i <= 6; ++ i) {
if(Alive(p ^ 1, pid[i])) {
z = pid[i];
++ c;
break;
}
}
// cerr << x << " " << y << " " << z << " " << c << " " << (1.35 / c) << endl;
double a = CalcAtk(p, id, 1.35 / c);
a *= ty[player[p][id].type][player[p ^ 1][x].type] * dir[(atkp - dgp + 6) % 6];
double d = CalcDef(p ^ 1, x);
int dec = floor(a / d + eps), rem = max(0, player[p ^ 1][x].nowhp - dec);
// cerr << x << ": " << a << " " << d << " " << dec << " " << rem << endl;
printf("%s %d took %d damage from %s %d -> %d/%d\n", team[p ^ 1], x, dec, team[p], id, rem, player[p ^ 1][x].maxhp);
player[p ^ 1][x].nowhp = rem;
if(y) {
double a = CalcAtk(p, id, 1.35 / c);
a *= ty[player[p][id].type][player[p ^ 1][y].type] * dir[(atkp - dgp + 6) % 6];
double d = CalcDef(p ^ 1, y);
// printf("%.15f %.15f %.15f\n", a, d, a / d);
int dec = floor(a / d + eps), rem = max(0, player[p ^ 1][y].nowhp - dec);
// cerr << y << ": " << a << " " << d << " " << dec << " " << rem << endl;
printf("%s %d took %d damage from %s %d -> %d/%d\n", team[p ^ 1], y, dec, team[p], id, rem, player[p ^ 1][y].maxhp);
player[p ^ 1][y].nowhp = rem;
}
if(z) {
double a = CalcAtk(p, id, 1.35 / c);
a *= ty[player[p][id].type][player[p ^ 1][z].type] * dir[(atkp - dgp + 6) % 6];
double d = CalcDef(p ^ 1, z);
int dec = floor(a / d + eps), rem = max(0, player[p ^ 1][z].nowhp - dec);
// cerr << z << ": " << a << " " << d << " " << dec << " " << rem << endl;
printf("%s %d took %d damage from %s %d -> %d/%d\n", team[p ^ 1], z, dec, team[p], id, rem, player[p ^ 1][z].maxhp);
player[p ^ 1][z].nowhp = rem;
}
player[p][id].skleff = 1;
}
if(player[p][id].wtype == 2) { // M
int x = tar, y = 0, z = 0;
for(int i = pos[tar] - 1; i > 0; -- i) {
if(Alive(p ^ 1, pid[i])) {
y = pid[i];
break;
}
}
for(int i = pos[tar] + 1; i <= 6; ++ i) {
if(Alive(p ^ 1, pid[i])) {
z = pid[i];
break;
}
}
double a = CalcAtk(p, id, 1.15);
a *= ty[player[p][id].type][player[p ^ 1][x].type] * dir[(atkp - dgp + 6) % 6];
double d = CalcDef(p ^ 1, x);
int dec = floor(a / d + eps), rem = max(0, player[p ^ 1][x].nowhp - dec);
printf("%s %d took %d damage from %s %d -> %d/%d\n", team[p ^ 1], x, dec, team[p], id, rem, player[p ^ 1][x].maxhp);
player[p ^ 1][x].nowhp = rem;
if(y) {
double a = CalcAtk(p, id, 0.23);
a *= ty[player[p][id].type][player[p ^ 1][y].type] * dir[(atkp - dgp + 6) % 6];
double d = CalcDef(p ^ 1, y);
int dec = floor(a / d + eps), rem = max(0, player[p ^ 1][y].nowhp - dec);
printf("%s %d took %d damage from %s %d -> %d/%d\n", team[p ^ 1], y, dec, team[p], id, rem, player[p ^ 1][y].maxhp);
player[p ^ 1][y].nowhp = rem;
}
if(z) {
double a = CalcAtk(p, id, 0.23);
a *= ty[player[p][id].type][player[p ^ 1][z].type] * dir[(atkp - dgp + 6) % 6];
double d = CalcDef(p ^ 1, z);
int dec = floor(a / d + eps), rem = max(0, player[p ^ 1][z].nowhp - dec);
printf("%s %d took %d damage from %s %d -> %d/%d\n", team[p ^ 1], z, dec, team[p], id, rem, player[p ^ 1][z].maxhp);
player[p ^ 1][z].nowhp = rem;
}
player[p][id].skleff = 1;
}
}
void Skill(int p, int id) {
int tar = 0;
tar = Parse();
if(player[p][id].type == weak) {
double eff = skl[player[p][id].type][player[p][id].skilllv];
int inc = floor(player[p][tar].maxhp * eff + eps), rem = min(player[p][tar].maxhp, player[p][tar].nowhp + inc);
printf("%s %d applied %s skill to %s %d\n", team[p], id, type[player[p][id].type], team[p], tar);
if(player[p][tar].maxhp > player[p][tar].nowhp) {
printf("%s %d recovered +%d hp -> %d/%d\n", team[p], tar, inc, rem, player[p][tar].maxhp);
}
player[p][tar].nowhp = rem;
}
if(player[p][id].type == average) {
player[p ^ 1][tar].rd = 3;
player[p ^ 1][tar].dechp = skl[player[p][id].type][player[p][id].skilllv];
printf("%s %d applied %s skill to %s %d\n", team[p], id, type[player[p][id].type], team[p ^ 1], tar);
}
if(player[p][id].type == strong) {
player[p][tar].skleff = skl[player[p][id].type][player[p][id].skilllv];
printf("%s %d applied %s skill to %s %d\n", team[p], id, type[player[p][id].type], team[p], tar);
}
}
void CalcDec(int p) {
for(int i = 1; i <= 6; ++ i) {
if(Alive(p, i) && player[p][i].rd) {
int dec = floor(player[p][i].maxhp * player[p][i].dechp + eps);
int rem = max(0, player[p][i].nowhp - dec);
printf("%s %d took %d damage from skill -> %d/%d\n", team[p], i, dec, rem, player[p][i].maxhp);
player[p][i].nowhp = rem;
-- player[p][i].rd;
}
}
}
int main() {
ty[weak][weak] = 1.0;
ty[weak][average] = 0.9;
ty[weak][strong] = 1.1;
ty[average][weak] = 1.1;
ty[average][average] = 1.0;
ty[average][strong] = 0.9;
ty[strong][weak] = 0.9;
ty[strong][average] = 1.1;
ty[strong][strong] = 1.0;
scanf("%d%d", &n[0], &n[1]);
for(int i = 1; i <= n[0]; ++ i) {
player[0][i].Read();
}
for(int i = 1; i <= n[1]; ++ i) {
player[1][i].Read();
}
pre[0] = pre[1] = 6;
scanf("%d", &q);
for(int i = 0; i < q; ++ i) {
int p = i & 1;
Passive(p);
int cho = -1;
for(int i = pre[p] + 1; i <= 6; ++ i) {
if(Alive(p, i)) {
cho = i;
break;
}
}
if(cho == -1) {
for(int i = 1; i <= 6; ++ i) {
if(Alive(p, i)) {
cho = i;
break;
}
}
}
pre[p] = cho;
assert(cho != -1);
char atktype[15];
scanf("%s", atktype + 1);
if(atktype[1] == 'B') {
Basic(p, cho);
}
else if(atktype[2] == 'p') {
Special(p, cho);
}
else {
Skill(p, cho);
}
CalcDec(p ^ 1);
for(int j = 1; j >= 0; -- j) {
printf("%s: ", team[j]);
for(int k = 1; k <= 6; ++ k) {
if(pid[k] <= n[j]) {
printf("%d/%d ", player[j][pid[k]].nowhp, player[j][pid[k]].maxhp);
}
}
puts("");
}
puts("");
// if(i == 2)
// break;
if(AllDead(p ^ 1)) {
printf("Team %s Won.\n", team[p]);
break;
}
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3784kb
input:
2 2 Weak Lv=25 maxhp=287601 atk=80590e-5 def=17668e-6 skillLv=5 passivesklLv=0 B weaponatk=30000e-2 Average Lv=31 maxhp=16405 atk=92912e-5 def=38987e-5 skillLv=0 passivesklLv=0 G weaponatk=30000e-2 Average Lv=91 maxhp=176604 atk=12532e-4 def=14815e-4 skillLv=4 passivesklLv=1 G weaponatk=14325e0 Weak...
output:
North 1 took 136 damage from South 1 -> 176468/176604 North: 176468/176604 864367/864367 South: 287601/287601 16405/16405 South 1 took 838265 damage from North 1 -> 0/287601 North: 176468/176604 864367/864367 South: 0/287601 16405/16405 North 2 took 0 damage from South 2 -> 864367/864367 North...
result:
wrong answer 45th lines differ - expected: 'Team North won.', found: 'Team North Won.'