【HDOJ】3587 NUDOTA

字符串模拟水题。

 /* 3587 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <map>
using namespace std; #define MAXN 1005 typedef struct {
bool f;
int k;
int t;
int v;
} hero_t; hero_t hero[MAXN*];
int nn = ;
char x[], y[];
map<string, int> tb;
map<string, int>::iterator iter; int main() {
int n, m, K;
int i, j, k, tmp;
char cmd[];
int t;
bool fb;
int ck[]; #ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
#endif ck[] = ck[] = ck[] = ;
for (i=; i<=; ++i)
ck[i] = ck[i-] + ; while (scanf("%d %d %d", &n, &m, &K) != EOF) {
nn = ;
tb.clear();
for (i=; i<n; ++i) {
scanf("%s", x);
tb[string(x)] = nn;
hero[nn].v = ;
hero[nn].k = ;
hero[nn].t = ;
hero[nn].f = true;
++nn;
}
for (i=; i<m; ++i) {
scanf("%s", x);
tb[string(x)] = nn;
hero[nn].v = ;
hero[nn].k = ;
hero[nn].t = ;
hero[nn].f = false;
++nn;
} fb = true;
while (K--) {
scanf("%s", cmd);
if (cmd[] == 'K') {
scanf("%s %s %d", x, y, &t);
i = tb[string(x)];
j = tb[string(y)];
if (hero[i].f ^ hero[j].f) {
k = ;
++hero[i].k;
if (fb) {
fb = false;
k += ;
}
if (hero[i].k > )
k += ck[];
else
k += ck[hero[i].k];
hero[i].v += (t-hero[i].t) + k;
hero[i].t = t;
}
hero[j].v = hero[j].v + (t-hero[j].t) - ;
hero[j].t = t;
hero[j].k = ;
if (hero[j].v < )
hero[j].v = ;
} else {
scanf("%s %d", x, &t);
i = tb[string(x)];
hero[i].v += (t - hero[i].t);
hero[i].t = t;
printf("%d\n", hero[i].v);
}
}
} return ;
}
上一篇:mysql修改删除列,删除有外键依赖的列


下一篇:Mysql利用binlog日志恢复数据操作(转)