字符串模拟水题。

 /* 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 ;
}

【HDOJ】3587 NUDOTA的更多相关文章

  1. 【HDOJ】4729 An Easy Problem for Elfness

    其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到 ...

  2. 【HDOJ】【3506】Monkey Party

    DP/四边形不等式 裸题环形石子合并…… 拆环为链即可 //HDOJ 3506 #include<cmath> #include<vector> #include<cst ...

  3. 【HDOJ】【3516】Tree Construction

    DP/四边形不等式 这题跟石子合并有点像…… dp[i][j]为将第 i 个点开始的 j 个点合并的最小代价. 易知有 dp[i][j]=min{dp[i][j] , dp[i][k-i+1]+dp[ ...

  4. 【HDOJ】【3480】Division

    DP/四边形不等式 要求将一个可重集S分成M个子集,求子集的极差的平方和最小是多少…… 首先我们先将这N个数排序,容易想到每个自己都对应着这个有序数组中的一段……而不会是互相穿插着= =因为交换一下明 ...

  5. 【HDOJ】【2829】Lawrence

    DP/四边形不等式 做过POJ 1739 邮局那道题后就很容易写出动规方程: dp[i][j]=min{dp[i-1][k]+w[k+1][j]}(表示前 j 个点分成 i 块的最小代价) $w(l, ...

  6. 【HDOJ】【3415】Max Sum of Max-K-sub-sequence

    DP/单调队列优化 呃……环形链求最大k子段和. 首先拆环为链求前缀和…… 然后单调队列吧<_<,裸题没啥好说的…… WA:为毛手写队列就会挂,必须用STL的deque?(写挂自己弱……s ...

  7. 【HDOJ】【3530】Subsequence

    DP/单调队列优化 题解:http://www.cnblogs.com/yymore/archive/2011/06/22/2087553.html 引用: 首先我们要明确几件事情 1.假设我们现在知 ...

  8. 【HDOJ】【3068】最长回文

    Manacher算法 Manacher模板题…… //HDOJ 3068 #include<cstdio> #include<cstring> #include<cstd ...

  9. 【HDOJ】【1512】Monkey King

    数据结构/可并堆 啊……换换脑子就看了看数据结构……看了一下左偏树和斜堆,鉴于左偏树不像斜堆可能退化就写了个左偏树. 左偏树介绍:http://www.cnblogs.com/crazyac/arti ...

随机推荐

  1. Swoole源代码学习记录(十五)——Timer模块分析

    swoole版本号:1.7.7-stable Github地址:点此查看 1.Timer 1.1.swTimer_interval_node 声明: // swoole.h 1045-1050h ty ...

  2. Badge分析&如何逼死处女座

    Badge分析 所谓Badge,原本是iOS上的一个效果,但是被Android抄的多了,也就成了Android的标配.图就不上了,大家都懂的. 应用icon显示角标实际上是在Launcher中实现的, ...

  3. Camera2Raw

    This sample demonstrates how to use the Camera2 API to capture RAW camera buffers and save them as D ...

  4. C# Wpf异步修改UI,多线程修改UI(二)

    1.使用定时器异步修改 这是相对比较简单的方法 在Wpf中定时器使用DiapatcherTimer,不使用Timer原因: 在一个应用程序中,Timer会重复生成time事件,而DispatcherT ...

  5. android Editview中加小图标或者文字实现

    关于这个问题,如果只是加小图标的话,已经提供了很好的支持,drawableLeft属性就可以设置左边的小图标,类推,右边也可以 不过如果你要加的是文字,我找了下,没有相应的属性,我们只能通过转换思路去 ...

  6. Linux命令--用户用户组管理

    新增用户组 : groupadd groupadd [-g GID] 组名 不加-g 则按照系统默认的gid创建组,跟用户一样,gid也是从500开始的 修改用户组信息 : groupmod grou ...

  7. myeclipse 'no default proposals' when use 'alt + /'.

    solution: Window -> Preferences -> Java -> Editor -> Content Assist -> Advanced in th ...

  8. Nginx反向代理配置配置实例

    为了节省支出,公司需要将分布在不同机器的站点都迁移到一台机器,而目前不同机器运行的是不同的web服务,部分是nginx,部分是apache,由于牵涉较多rewrite规则,为了节省修改功夫,打算迁移后 ...

  9. MySQL主从复制详细部署过程

    环境介绍:   采用多实例进行主从复制测试,多实例方法请参考网上其它文档,其实多实例和双服务器对于测试环境来说是一样的.   当前采用3306端口进程为Master,3307端口进程为Slave.   ...

  10. python3 解析apk图标

    有两处值小点,一是如何解压缩,另一个是如何写文件,第二点上我找的是phthon2的代码,一直写文件的时候报不是字符串的问题,将打开方式加上"b“的模式搞定 print文件出来直接删除了,原因 ...