Implement a data structure supporting the following operations: Inc(Key) - Inserts a new key with value 1. Or increments an existing key by 1. Key is guaranteed to be a non-empty string. Dec(Key) - If Key's value is 1, remove it from the data structu
Find Median from Data Stream Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value. Examples: [2,3,4] , the median is 3 [2,3], the median is
E. Exposition Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/6/E Description There are several days left before the fiftieth birthday of a famous Berland's writer Berlbury. In this connection the local library d
B. Strip Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/487/problem/B Description Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right. Now Alexandra wants to split it into some pieces (p
Hoax or what 题意是询问一个动态序列的最小值和最大值. 可以用multiset来实现. #include <stdio.h> #include <set> using namespace std; int main() { freopen("h.in", "r", stdin); freopen("h.ans", "w", stdout); int n; while (scanf("
A A monster is attacking the Cyberland! Master Yang, a braver, is going to beat the monster. Yang and the monster each have 3 attributes: hitpoints (HP), offensive power (ATK) and defensive power (DEF). During the battle, every second the monster's H
题解:先从节点1开始dfs.对于每一个节点,用一个set记录:以该点为根的子树的深度. a) 如果此节点的某个子节点打出了GG,则此节点直接打出GG. b) 若set的元素个数<=1,那么,以该点为根的子树,显然是可以缩成一条链滴!且该点为链的端点.c) 若set元素个数=2,以该点为根的子树,也可以收缩成一条链,且该点不是链的端点.此时,我们继续分类讨论. i) 该点没有父亲.我们成功找到了一条链~岂不美哉. ii) 该点有父亲,那么在链上会长出一根奇怪的东西.那我们赶紧报警,把该点赋给roo
E. Exposition time limit per test 2 seconds memory limit per test 64 megabytes input standard input output standard output There are several days left before the fiftieth birthday of
Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value. Examples: [2,3,4] , the median is 3 [2,3], the median is (2 + 3) / 2 = 2.5 Given an a
Contest2071 - 湖南多校对抗赛(2015.03.28) 本次比赛试题由湖南大学ACM校队原创 http://acm.csu.edu.cn/OnlineJudge/contest.php?cid=2071 Problem A: Rectangle Time Limit: 1 Sec Memory Limit: 256 MBSubmit: 210 Solved: 48[Submit][Status][Web Board] Description Now ,there are some