C - Watchmen CodeForces - 651C (使用map例题)
#include<iostream>#include<map> using namespace std;map<int,int> x;map<int,int> y;map<pair<int,int>,int> xy;int main(){ int n; cin>>n; for(int i=0;i<n;++i) { int xx,yy; scanf("%d%d",&xx,&yy); ++x[xx]; ++y[yy]; ++xy[make_pair(xx,yy)]; } long long ans=0; for(auto i : x) ans+=(long long)i.second*((long long)i.second-1)/2; for(auto i : y) ans+=(long long)i.second*((long long)i.second-1)/2; for(auto i : xy) ans-=(long long)i.second*((long long)i.second-1)/2; printf("%lld",ans); }
C - Watchmen CodeForces - 651C (使用map例题)的更多相关文章
- codeforces 651C(map、去重)
题目链接:http://codeforces.com/contest/651/problem/C 思路:结果就是计算同一横坐标.纵坐标上有多少点,再减去可能重复的数量(用map,pair存一下就OK了 ...
- Watchmen CodeForces - 650A
Watchmen CodeForces - 650A Watchmen are in a danger and Doctor Manhattan together with his friend Da ...
- Go map例题
package main import "fmt" //map例题 //寻找最长不含有重复字符的子串 // abcabcbb -> abc //pwwkew ->wke ...
- CodeForces 651C Watchmen map
Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn t ...
- 【CodeForces - 651C 】Watchmen(map)
Watchmen 直接上中文 Descriptions: 钟表匠们的好基友马医生和蛋蛋现在要执行拯救表匠们的任务.在平面内一共有n个表匠,第i个表匠的位置为(xi, yi). 他们需要安排一个任务计划 ...
- codeforces 651C Watchmen
Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn t ...
- CodeForces - 651C Watchmen (去重)
Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn t ...
- Codeforces 651C Watchmen【模拟】
题意: 求欧几里得距离与曼哈顿距离相等的组数. 分析: 化简后得到xi=xj||yi=yj,即为求x相等 + y相等 - x与y均相等. 代码: #include<iostream> #i ...
- CodeForces 651C
Description Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg s ...
- A. Watchmen(Codeforces 650A)
A. Watchmen time limit per test 3 seconds memory limit per test 256 megabytes input standard input o ...
随机推荐
- golang运算符
1.算术运算符 算术运算符有:+,-,*,/,%,++,-- 1.1 加号(+) 表示正数 数字相加 字符串拼接 package main import ( "fmt" ) fun ...
- 发现一个API接口自动化测试平台
gitee地址:https://gitee.com/season-fan/autometer-api 记录一下: 1.API测试平台的5个需求: ①支持不同的项目,不同的角色,技术人员多人协作 ②支持 ...
- Github好用的镜像网站
最近Github越来越不好用了,发现一个特别好用的镜像网站,无论是进入还是下载都非常的快. https://hub.yzuu.cf/ 首页和Github没有任何区别, 注意请不要在连着梯子的时候使用, ...
- 蓝牙mesh组网实践(dataflash的占用与管理)
目录 蓝牙mesh协议中有不少数据需要存储dataflash,以记录网络中的数据.一些数据只需要配网时保存进dataflash,比如说本节点的网络地址.各类密钥等:另一些数据需要在运行中动态更新,比如 ...
- 用requests-html和SelectorGadget轻松精准抓取网页数据
我们在抓取网页数据时,最常採用Python的requests搭配BeautifulSoup的模式来完成.然而,requests-html整合了上述2个套件,又添加了新的功能,或许是抓取网页数据值得考虑 ...
- JS中立即执行函数和闭包的区别
函数声明规则:必须指定一个函数名字 foo(); function foo() { console.log("函数声明") } 由于函数声明会被提升,所以调用函数可以在之前或之后调 ...
- JSR 133
JSR 133是Java语言规范的一个JSR(Java Specification Request),全称为Java Memory Model and Thread Specification R ...
- 免费赠票 | Cloud Ace 受邀参加 GTC2022 全球流量大会,助力中国企业扬帆出海!
Cloud Ace 受邀参加 GTC2022 全球流量大会,助力中国企业扬帆出海! 大会将在 2023 年 2 月 28 日-3 月 1 日举行,地点就在福田会展中心 6 号展馆.大会门票实行收费 ...
- verilog 和system verilog 文件操作
1. 文件操作 Verilog具有系统任务和功能,可以打开文件.将值输出到文件.从文件中读取值并加 载到其他变量和关闭文件. 1.1 Verilog文件操作 1.1.1 打开和关闭文件 module ...
- 从main_phase跳回reset_phase的方式
在main_phase中调用: phase.jump(uvm_reset_phase::get()); 注意需要防止进入死循环.