P5006 大美江湖
#include<bits/stdc++.h>
using namespace std;
int hp, mhp, st, de, mst, mde;
char mp[101][101];
int maxhp;
int x, y;
int n, m, q;
void move(int &x, int &y, int d);
void check(int x, int y);
int main()
{
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
cin >> mp[i][j];
cin >> mhp >> mst >> mde;
cin >> x >> y;
cin >> hp >> st >> de;
maxhp = hp;
cin >> q;
while (q--)
{
int op;
cin >> op;
if (op & 1)
{
cout << hp << ' ' << st << ' ' << de << '\n';
}
else
{
int d;
cin >> d;
move(x, y, d);
}
}
return 0;
}
void move(int &x, int &y, int d)
{
int new_x = x, new_y = y;
if (d == 1) new_y--;
else if (d == 2) new_y++;
else if (d == 3) new_x--;
else if (d == 4) new_x++;
if (new_x < 1 || new_x > n || new_y < 1 || new_y > m) return;
check(new_x, new_y);
x = new_x;
y = new_y;
}
void check(int x, int y)
{
if (mp[x][y] == 'R') hp = min(maxhp, hp + 10);
else if (mp[x][y] == 'Q') st += 5;
else if (mp[x][y] == 'Y') de += 5;
else if (mp[x][y] == 'M')
{
int damage = max(1, (int)ceil((double)max(1, st - mde) / mhp) * max(1, mst - de));
hp -= damage;
if (hp < 0) hp = 0;
}
}