#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例题)的更多相关文章

  1. codeforces 651C(map、去重)

    题目链接:http://codeforces.com/contest/651/problem/C 思路:结果就是计算同一横坐标.纵坐标上有多少点,再减去可能重复的数量(用map,pair存一下就OK了 ...

  2. Watchmen CodeForces - 650A

    Watchmen CodeForces - 650A Watchmen are in a danger and Doctor Manhattan together with his friend Da ...

  3. Go map例题

    package main import "fmt" //map例题 //寻找最长不含有重复字符的子串 // abcabcbb -> abc //pwwkew ->wke ...

  4. CodeForces 651C Watchmen map

    Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn t ...

  5. 【CodeForces - 651C 】Watchmen(map)

    Watchmen 直接上中文 Descriptions: 钟表匠们的好基友马医生和蛋蛋现在要执行拯救表匠们的任务.在平面内一共有n个表匠,第i个表匠的位置为(xi, yi). 他们需要安排一个任务计划 ...

  6. codeforces 651C Watchmen

    Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn t ...

  7. CodeForces - 651C Watchmen (去重)

    Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn t ...

  8. Codeforces 651C Watchmen【模拟】

    题意: 求欧几里得距离与曼哈顿距离相等的组数. 分析: 化简后得到xi=xj||yi=yj,即为求x相等 + y相等 - x与y均相等. 代码: #include<iostream> #i ...

  9. CodeForces 651C

    Description Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg s ...

  10. A. Watchmen(Codeforces 650A)

    A. Watchmen time limit per test 3 seconds memory limit per test 256 megabytes input standard input o ...

随机推荐

  1. [转载]Net分布式系统之四:RabbitMQ消息队列应用

    消息通信组件Net分布式系统的核心中间件之一,应用与系统高并发,各个组件之间解耦的依赖的场景.本框架采用消息队列中间件主要应用于两方面:一是解决部分高并发的业务处理:二是通过消息队列传输系统日志.目前 ...

  2. webpack5基础用法2

    webpack的基础用法2 webpack的优化方向 提升开发体验 提升打包构建速度 减少代码体积 优化代码运行性能 SourceMap 生成一个.map文件,形成一个映射, 可以通过错误找到源文件 ...

  3. Svn Linux 启动

    svnserve -r -d /svn 后面是svn 安装目录

  4. Hadoop2.x伪分布式环境搭建(一)

    1.安装hadoop环境,以hadoop-2.5.0版本为例,搭建伪分布式环境,所需要工具包提供网盘下载:http://pan.baidu.com/s/1o8HR0Qu 2.上传所需要的工具包到lin ...

  5. MobilePBRLighting优化思路2

    在最近的研究工作中,进一步对移动端PBRLighting进行了优化,以下是一些优化截图,由于后续整理文章使用: PBRLighting(未开启伽马矫正): MobilePBRLighting(高质量版 ...

  6. python 小顶堆

    from heapq import *heap=[]for i in range(10,1,-1): heappush(heap,i)print(heap)print(heappop(heap))pr ...

  7. python函数传参是传值还是指针

    python中,往函数传参传的是指针,并非传值. 代码说话 如果改变函数参数的值,我们来看看改变: 但是如果是传的列表这种可变数据类型呢 传列表并没有发送改变,仍然指向的是原来的地址. 这是因为传的数 ...

  8. 二分查找中mid值的计算方法

    在刷题的时候遇到许多二分查找的题目 发现很多大佬的题解中mid值得计算都是用的:mid = low + (high-low)/ 2; 为什么不用mid = (low+high)/ 2的计算方法呢? i ...

  9. WPF-窗体移动,最小化,最大化,关闭

    1,按钮操作 public MainView() { InitializeComponent(); this.MaxHeight = SystemParameters.PrimaryScreenHei ...

  10. Springboot+thymeleaf结合Vue,通过thymeleaf给vue赋值解决Vue的SEO问题

    前言 vue开发的项目有时候会有SEO的需求,由于vue是JavaScript框架,内容都在JavaScript和服务端,所以SEO效果很差.vue的服务端渲染又很难和现在成熟的springboot等 ...