【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 ;
}
【HDOJ】3587 NUDOTA的更多相关文章
- 【HDOJ】4729 An Easy Problem for Elfness
其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到 ...
- 【HDOJ】【3506】Monkey Party
DP/四边形不等式 裸题环形石子合并…… 拆环为链即可 //HDOJ 3506 #include<cmath> #include<vector> #include<cst ...
- 【HDOJ】【3516】Tree Construction
DP/四边形不等式 这题跟石子合并有点像…… dp[i][j]为将第 i 个点开始的 j 个点合并的最小代价. 易知有 dp[i][j]=min{dp[i][j] , dp[i][k-i+1]+dp[ ...
- 【HDOJ】【3480】Division
DP/四边形不等式 要求将一个可重集S分成M个子集,求子集的极差的平方和最小是多少…… 首先我们先将这N个数排序,容易想到每个自己都对应着这个有序数组中的一段……而不会是互相穿插着= =因为交换一下明 ...
- 【HDOJ】【2829】Lawrence
DP/四边形不等式 做过POJ 1739 邮局那道题后就很容易写出动规方程: dp[i][j]=min{dp[i-1][k]+w[k+1][j]}(表示前 j 个点分成 i 块的最小代价) $w(l, ...
- 【HDOJ】【3415】Max Sum of Max-K-sub-sequence
DP/单调队列优化 呃……环形链求最大k子段和. 首先拆环为链求前缀和…… 然后单调队列吧<_<,裸题没啥好说的…… WA:为毛手写队列就会挂,必须用STL的deque?(写挂自己弱……s ...
- 【HDOJ】【3530】Subsequence
DP/单调队列优化 题解:http://www.cnblogs.com/yymore/archive/2011/06/22/2087553.html 引用: 首先我们要明确几件事情 1.假设我们现在知 ...
- 【HDOJ】【3068】最长回文
Manacher算法 Manacher模板题…… //HDOJ 3068 #include<cstdio> #include<cstring> #include<cstd ...
- 【HDOJ】【1512】Monkey King
数据结构/可并堆 啊……换换脑子就看了看数据结构……看了一下左偏树和斜堆,鉴于左偏树不像斜堆可能退化就写了个左偏树. 左偏树介绍:http://www.cnblogs.com/crazyac/arti ...
随机推荐
- EditText 密码属性
<EditText android:id="@+id/et_password" android:layout_width="match_parent" a ...
- 谈论C++当然结果
C++编程课程的考试已经结束.这是第一次OJCBT.摸着石头过河,考试没有给学生理解的说法.现在尘埃落定.一些交代. 先说大的成就的治疗原则.事实上,有很多的纠结. 按理说,合格的太,无法挂.但实际情 ...
- php 自定义求数组差集,效率比自带的array_diff函数还要快(转)
<?phpfunction array_different($array_1, $array_2) { $array_2 = array_flip($array_2); //将数组键值调换 fo ...
- Linux 下实现控制屏幕显示信息和光标的状态
//display.h /************************************************************* FileName : display.h File ...
- Swift的闭包(二):捕获值
闭包可以从定义它的上下文中捕获常量和变量. 在Swift中,捕获值最简单的例子是嵌套函数,举个例子: func makeIncrementer(forIncrement amount: Int) -& ...
- 如何开通www国际域名个人网站
欢迎访问我的域名http://www.baiqiantao.xyz 一.准备知识 什么是域名? 所有以www开头的域名,就是国际域名:不以www开头的域名,都是为子域名. 域名都有后缀,后缀是有意义的 ...
- codevs2034 01串2
/* 一开始认为是个水题 直接模拟 没想到只得了50分 一看数据吓niao了 模拟妥妥的TLE 实在不好优化了0.0(最快O(m)) 然后借鉴别人的 DP+神奇的输出 DP:状态:f[i][j] 前i ...
- 操作iis
以后研究 try { string method = "Recycle"; string AppPoolName = "z.chinabett.com"; Di ...
- (转)dedecms代码详解 很全面
dedecms代码研究(1)开篇dedecms 相信大家一定都知道这个cms 系统,功能比较强大,有比较完善的内容发布,还有内容静态化系统,还有就是它有自己独特的标签系统和模板系统.而模板系统也是其他 ...
- phpstudy apache 刚启动便停止
1.添加站点 2.重启服务 3.遇见问题 apache 刚启动,1秒钟中后就停止 4.解决问题 发现是自己添加的网站中包含中文路径的问题,建议不要在自己的网站目录下包含中文.