题目:给你n(<=2*1e5)个点,求其中有多少个点对之间的连线向量平行坐标轴: #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <vector> #include <queue> #include <stack> #include <map&g…
A. Watchmen time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. The…
Watchmen 题意:有n (1 ≤ n ≤ 200 000) 个点,问有多少个点的开平方距离与横纵坐标的绝对值之差的和相等: 即 = |xi - xj| + |yi - yj|.(|xi|, |yi| ≤ 109) 思路:开始想的是容斥原理,即按x,y分别排序,先计算同x的点,然后在计算同y的点,这时由于相同的点之间的连边已经算过了,这样就不能再算.并且同一个y的点中可以每个点有多个点,算是不好编码的(反正我敲了很久..WA了) 反思:上面的容斥原理是从总体的思路来考虑的,这道题的难点也就是…
C. Watchmen 题目连接: http://www.codeforces.com/contest/651/problem/C Description 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 watch…
题意:给你\(n\)个点,求这\(n\)个点中,曼哈顿距离和欧几里得距离相等的点对数. 题解: 不难发现,当两个点的曼哈顿距离等于欧几里得距离的时候它们的横坐标或者纵坐标至少有一个相同,可以在纸上画一画,当两点不满足上文所说的情况时,他们的曼哈顿距离一定大于直线距离,因为三角形的两边必定大于第三边,然后我们边输入边求,用桶分别存横和纵坐标,每次出现都将目前桶的值贡献给答案,但是两个相同的点应该只算一次贡献,我们要再开一个桶来减去重复的次数. 代码: int n; map<ll,ll> mpx,…
 cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....       其实这个应该是昨天就写完的,不过没时间了,就留到了今天.. 地址:http://codeforces.com/contest/651/problem/A A. Joysticks time limit per test 1 second memory limit per test 256…
Codeforces #345 Div.1 打CF有助于提高做题的正确率. Watchmen 题目描述:求欧拉距离等于曼哈顿距离的点对个数. solution 签到题,其实就是求有多少对点在同一行或同一列. 时间复杂度:\(O(nlogn)\) Image Preview 题目描述:给定看一张照片的时间,翻页的时间,把图片翻转的时间.一开始屏幕显示第一张照片,可以向左或向右翻,不能跳过还没有看过的图片,方向不对的图片要先翻转再看,看过的不消耗翻转时间与看照片时间,问在一定时间内,最多能看多少张照…
DFS A - Joysticks 嫌麻烦直接DFS暴搜吧,有坑点是当前电量<=1就不能再掉电,直接结束. #include <bits/stdc++.h> typedef long long ll; const int N = 1e5 + 5; int ans = 0; void DFS(int a, int b, int step) { if (a <= 0 || b <= 0) { ans = std::max (ans, step); return ; } if (a…
C. Table Compression Little Petya is now fond of data compression algorithms. He has already studied gz, bz, zip algorithms and many others. Inspired by the new knowledge, Petya is now developing the new compression algorithm which he wants to name d…
Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Similarly,…