字符串模拟水题。

 /* 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. [PWA] 2. Service worker life cycle

    Once serive worker is registered, the first time we go to the app, we cannot see the logs from servc ...

  2. hook研究结果备忘

    hook研究结果: 最近一周时间仔细研究了一下hook,也许不能称之为研究吧.顶多是让别人的思想拿过来抄袭一遍而已,写点结果也算对得起自己的这几天的苦心了. 1,首先从同事旁边听到了hook,然后看的 ...

  3. Java 8 Features – The ULTIMATE Guide--reference

    Now, it is time to gather all the major Java 8 features under one reference post for your reading pl ...

  4. 4道过滤菜鸟的iOS面试题

    网上已经有很多针对各种知识点的面试题,面试时有些人未必真正理解也能通过背题看上去很懂.我自己总结了4道面试题,好快速的判断这个人是否是一个合格的工程师,欢迎大家点评. 1.struct和class的区 ...

  5. C#“简单加密文本器”的实现

    本示例只能加密英文文本,使用的算法为异或算法.源代码:http://pan.baidu.com/share/link?shareid=3241348313&uk=1761850335(本示例属 ...

  6. Android短信的发送和接收监听

    /**发送与接收的广播**/ String SENT_SMS_ACTION = "SENT_SMS_ACTION"; String DELIVERED_SMS_ACTION = & ...

  7. Android(java)学习笔记227:服务(service)之服务的生命周期 与 两种启动服务的区别

    1.之前我们在Android(java)学习笔记171:Service生命周期 (2015-08-18 10:56)说明过,可以回头看看: 2.Service 的两种启动方法和区别: (1)Servi ...

  8. 运用linq查找所有重复的元素

    如题: 有一个List<string>类型的List<T> List<String> list = "};` 需要返回结果List包含 {"6& ...

  9. gui线程

    package thread; import java.awt.BorderLayout; import java.awt.EventQueue; import java.awt.event.Acti ...

  10. linux进程创建

    1.  进程是程序的执行,会被加载到内存中,每个进程包括程序的代码和数据,其中数据包括程序的变量的数据,外部数据,程序堆栈. 2. Linux中,输入命令,如vi main.c 通过shell来执行, ...