【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 ...
随机推荐
- hdu 4602 Partition (概率方法)
Partition Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- [转] nodeJS的post提交简单实现
index.js: ? 1 2 3 4 5 6 7 8 var server = require('./server'); var router = require('./route'); var r ...
- iOS异步图片加载优化与常用开源库分析
网络图片显示大体步骤: 1.下载图片: 2.图片处理(裁剪,边框等): 3.写入磁盘: 4.从磁盘读取数据到内核缓冲区: 5.从内核缓冲区复制到用户空间(内存级别拷贝): 6.解压缩为位图(耗cpu较 ...
- Android系统移植与驱动开发--第四章
第四章 源代码的下载和编译 一个android内核相当于4G,而一个Linux内个只有几百M,Linux内核相对于android内核来说实在是小巫见大巫.了解android源代码不一定要详细了解,只去 ...
- 转载:C# 中的委托
原文地址 http://www.tracefact.net/CSharp-Programming/Delegates-and-Events-in-CSharp.aspx 感谢博主分享! 引言 委托和 ...
- 移动页面缩放方法之(一)控制meta法
<!DOCTYPE HTML> <html lang="zh-cn"> <head> <meta http-equiv="Con ...
- 谷歌插件postman如果不能用,就用git命令发送post请求
curl -X POST --data '{"name":"zfpx"}' -H 'Content-Type:application/json' http:/ ...
- (转)PHP数组的总结(很全面啊)
一.什么是数组数组就是一组数据的集合,把一系列数据组织起来,形成一个可操作的整体.数组的每个实体都包含两项:键和值. 二.声明数据在PHP中声明数组的方式主要有两种:一是应用array()函数声明数组 ...
- Mavne + Spring整合CXF
http://blog.csdn.net/xiongyu777888/article/details/23787615(没毛病) http://blog.csdn.net/hbsong75/artic ...
- Objective-C内存管理与原理
尽管苹果在 iOS 5/ Mac OS X 10.7 开始导入ARC,利用 Xcode4.2 可以使用该机能.ARC就是自动引用计数,是一项为Objective - C程序在编译时提供自动内存管理的功 ...