codeforces 651C(map、去重)】的更多相关文章

题目链接:http://codeforces.com/contest/651/problem/C 思路:结果就是计算同一横坐标.纵坐标上有多少点,再减去可能重复的数量(用map,pair存一下就OK了). #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair <int,int> pii; const int N = 2e5 + 5; map <int,int> x,…
Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are n watchmen on a plane, the i-th watchman is located at point (xi, yi). They need to arrange a plan, but there are s…
Watchmen 直接上中文 Descriptions: 钟表匠们的好基友马医生和蛋蛋现在要执行拯救表匠们的任务.在平面内一共有n个表匠,第i个表匠的位置为(xi, yi). 他们需要安排一个任务计划,但是确发现了一些问题很难解决.马医生从第i个表匠到第j个表匠所需要的时间为|xi - xj| + |yi - yj|.然而蛋蛋所需要的时间为 要想成功完成任务,必须保证两人从第i个表匠出发,同时到达第j个表匠.现在请你计算最多有多少组表匠的位置满足条件 Input 第一行只有一个数n( 1 ≤ n…
Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are n watchmen on a plane, the i-th watchman is located at point (xi, yi). They need to arrange a plan, but there are s…
Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are n watchmen on a plane, the i-th watchman is located at point (xi, yi). They need to arrange a plan, but there are s…
 Fibonacci-ish Time Limit: 3000MS   Memory Limit: 524288KB   64bit IO Format: %I64d & %I64u Submit Status Description Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if the seque…
Map<Integer,String>,Integer代表时间撮,String代表文本信息去重函数:就是删除Map中value相同的元素,只保留key最小的那个元素 public static Map<Integer,String> RemoveRepFromMap(Map<Integer,String> map){ Set<Entry<Integer,String>> set = map.entrySet(); List<Entry<…
题目链接 题目意思很简单nm的矩阵里, 选若干个ab的小矩阵, 定义每个矩阵的值为这个矩阵里的所有数的和-最小值*数的个数. 选小矩阵时, 优先选值最小的,然后次小的.. 知道不能选位置. 输出所有矩阵的左上角那个数的坐标以及这个矩阵的值. 思路很简单, 将所有矩阵的值加到一个优先队列里面, 然后一个一个的删除. 直到矩阵空. 不好做的是求一个矩阵中的最小值. 我先是用二维线段树, tle. 然后用二维st表, mle.... 然后看cf上的代码 ,用一个multiset来搞. 具体看代码..…
数据格式 [ { "id":"d3e8a9d6-e4c6-4dd8-a94f-07733d3c1b59", "parentId":"6d460008-38f7-479d-b6d1-058ebc17dae3", "myorder":1, "name":"任务一" }, { "id":"6d460008-38f7-479d-b6d1-058e…
大意: 给定字符串, 每次可以任选一个字符$x$, 将$x$左侧或右侧也改为$x$, 求最终能得到多少种字符串. 首先可以观察到最终字符串将连续相同字符合并后一定是原字符串的子序列 并且可以观察到相同长度(设为m)的子序列能产生的最终字符串种类数是相同的. 即$\binom{n-1}{m-1}$ (可以通过排列后m-1个字符首次出现位置得到). 然后问题就转化为求原字符串相邻字符不同且本质不同的子序列个数. 前缀优化一下复杂度为$O(n^2)$ #include <iostream> #inc…