CodeForces - 650A(104/600)

SAS learning_3:sorting, printing, and summarize ur data( the little SAS book notes) ** 写在开头:此为自己学习little SAS book 的学习笔记,有很多内容会与书中重复。数据集我尽量使用SAS自带数据集,以方便大家重复出来。 ** 之前一直使用的文本编辑器做笔记,发现效果不好,没有结果展示,自己回过头来看还是比较费时间,因此下定决心以后都在此博客下记录自己学习的点点滴滴。 本次使用的是SAS的学生数据。(SAShelp.Class) 一. 使用SAS PROC 1. P... 阅读详情

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 some difficulties on their way. As you know, Doctor Manhattan considers the distance between watchmen i and j to be |xi - xj| + |yi - yj|. Daniel, as an ordinary person, calculates the distance using the formula .

The success of the operation relies on the number of pairs (i, j) (1 ≤ i < j ≤ n), such that the distance between watchman i and watchmen j calculated by Doctor Manhattan is equal to the distance between them calculated by Daniel. You were asked to compute the number of such pairs.

Input
The first line of the input contains the single integer n (1 ≤ n ≤ 200 000) — the number of watchmen.

Each of the following n lines contains two integers xi and yi (|xi|, |yi| ≤ 109).

Some positions may coincide.

Output
Print the number of pairs of watchmen such that the distance between them calculated by Doctor Manhattan is equal to the distance calculated by Daniel.

Example
Input
3
1 1
7 5
1 5
Output
2
Input
6
0 0
0 1
0 2
-1 1
0 1
1 1
Output
11
Note
In the first sample, the distance between watchman 1 and watchman 2 is equal to |1 - 7| + |1 - 5| = 10 for Doctor Manhattan and for Daniel. For pairs (1, 1), (1, 5) and (7, 5), (1, 5) Doctor Manhattan and Daniel will calculate the same distances.

很容易能证明这种点必须是同一条x或者y

然后只要map大力去重就可以了

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<functional>
#include<vector>
#include<cstring>
#include<string>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stack>
#include<set>
using namespace std;
map<long long , long long >lsx, lsy;
long long  xx[200001], yy[200001],lisx[200001],lisy[200001],xg=0,yg=0;
long long  xxi[200001], yyi[200001];
map<long long , long long >mp[200001];
int main()
{
    long long  n,q,w;
    cin >> n;
    for (long long  a = 1; a <= n; a++)
    {
        scanf("%I64d%I64d", &q, &w);
        xx[a] = q, yy[a] = w;
        if (!lsx[q])
        {
            lisx[++lisx[0]] = q;
            lsx[q] = 1;
        }
        if (!lsy[w])
        {
            lisy[++lisy[0]] = w;
            lsy[w] = 1;
        }
    }
    lsx.clear(), lsy.clear();
    xg = lisx[0], yg = lisy[0];
    sort(lisx + 1, lisx + xg + 1);
    sort(lisy + 1, lisy + yg + 1);
    for (long long  a = 1; a <= xg; a++)lsx[lisx[a]] = a;
    for (long long  a = 1; a <= yg; a++)lsy[lisy[a]] = a;
    for (long long  a = 1; a <= n; a++)
    {
        xxi[lsx[xx[a]]]++;
        yyi[lsy[yy[a]]]++;
    }
    long long dan = 0;
    for (long long  a = 1; a <= xg; a++)dan += xxi[a]*(xxi[a] - 1)/2;
    for (long long  a = 1; a <= yg; a++)dan += yyi[a]*(yyi[a] - 1)/2;
    for (long long  a = 1; a <= n; a++)
    {
        long long  qq = lsx[xx[a]], ww = lsy[yy[a]];
        mp[qq][ww]++;
    }
    for (long long  a = 1; a <= xg; a++)
    {
        for (auto b : mp[a])
        {
            dan -= b.second*(b.second - 1) / 2;
        }
    }
    printf("%I64d", dan);
}
Comsol固体力学仿真﹣﹣受均匀内压的厚壁球壳弹塑性分析(加载卸载全流程) COMSOL固体力学及结构力学仿真较少,故而查询了有关资料,才建立了如下模型。图4 加载卸载全历程中的冯米塞斯应力变化。该有限元模型是通过扫掠而得的结构化网格。图2 加载卸载全历程中的塑型区域变化。图3 加载卸载全历程中的位移应力变化。图6 关键节点第一,第三主应力分布。图5 关键节点应力场与塑性区分布。《弹塑性力学》大作业,记录一下。图1 球体的有限元网格模型。 阅读详情

相关推荐

Yolov5自学笔记之一--从入门到入狱,功能强大不要乱用(实现yolov5的基本功能使用流程及训练自己的数据集)

零基础自学yolov5,学会简单使用和训练自己的数据集,在自己工作中使用

qq_41597915的博客 1万+

CF 650A Watchmen

A. Watchmen time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard output Watchmen are in a danger and Doctor Manhattan together with his friend Daniel

浮生匆忙,与君同往 650

YOLOv8中间特征层可视化

在通过观察这些特征,可以清楚地看到模型如何逐步将输入图像转化为有意义的表示。

weixin_45314480的博客 6905

codeforces 651C. Watchmen(排列,去重)

题目链接:http://codeforces.com/contest/651/problem/C C. Watchmen time limit per test 3 seconds memory limit per test 256 megabytes input standard input output st

hkh746392783的专栏 1400

UE4_后期处理六—夜视仪、扫描线

观察下面一组蓝图节点的效果:当把角色的自定义深度通道开启:画面效果如图:这样我们就得到了一个这样的黑白蒙版。

Growthofnotes的博客 1735

DDR内存设计必看:DFI接口协议详解与实战避坑指南(附时序图解析)

本文深入解析了DDR内存设计中连接内存控制器与物理层的DFI接口协议,聚焦于DDR4/DDR5设计的实际痛点。文章详细阐述了协议版本兼容性、时钟架构(匹配频率与频率比系统)、PCB信号完整性设计以及上电初始化与调试等关键环节,为硬件工程师提供了一套从理论到实战的完整避坑指南,并附有时序图解析以助理解。

weixin_29256771的博客 343

Watchmen

Watchmen 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 p...

leihao-lester 306

【PCIe 总线及设备入门学习专栏 6.2 -- PCIe VDM (Vendor Defined Messages)】

在PCIe协议中,Vendor Defined Messages (VDMs) 是一种允许厂商定义和传输特定功能的消息类型。这种机制扩展了标准 PCIe 消息的功能,可以用于实现供应商自定义的功能,例如固件更新、设备配置和诊断信息传输。PCIe VDM 是通过实现的,它遵循 PCIe 协议栈的结构,包括事务层、数据链路层和物理层。

CodingCos的博客 1914

codeforces 651C. Watchmen

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 watchman is loca

WOLF的博客 460

《Python基础教程》内容总览篇(持续更新中)

大家好,我是爱编程的喵喵。双985硕士毕业,现担任全栈工程师一职,热衷于将数据思维应用到工作与生活中。从事机器学习以及相关的前后端开发工作。曾在阿里云、科大讯飞、CCF等比赛获得多次Top名次。现为CSDN博客专家、人工智能领域优质创作者。喜欢通过博客创作的方式对所学的知识进行总结与归纳,不仅形成深入且独到的理解,而且能够帮助新手快速入门。个人精心开设的《Python基础课程》专栏订阅量接近900,帮助不少同学解决了Bug。

weixin_43178406的博客 35万+

4、分布式发电系统中用于改善电能质量的有源、无源和混合滤波器

本文探讨了分布式发电系统中,尤其是光伏(PV)系统运行过程中引入的电能质量问题,并分析了有源滤波器、无源滤波器及混合滤波器在改善电能质量方面的应用。文章详细介绍了光伏系统的建模、最大功率点跟踪(MPPT)技术,以及谐波、电压波动等技术问题,同时对各类滤波器的拓扑结构和控制方法进行了系统性总结。通过仿真实例比较了不同滤波器在减少谐波方面的效果,为实际工程应用提供了参考依据。

transformer2023的博客 96

牛客网练习题整理(1)

(1)关于浮点型double 以下数字在表示为double(8字节的双精度浮点数)时存在舍入误差的有()。 2的平方根 10的30次方 0.1 0.5 100 A. 2的平方根,本身就是无限小数,因此肯定有舍入误差 B. 10的30次方,明显超出了double的数据存储范围,故有舍入误差 C. 0.1不能用2的负整数次方来表示,因此有误差 D.0.5 = 2^...

咸鱼梦想 745

11、机器学习中的聚类与隐马尔可夫模型

本文介绍了机器学习中的两种重要方法:聚类算法和隐马尔可夫模型(HMM)。聚类作为无监督学习的代表,适用于发现无标签数据中的结构,常见算法包括K-均值和自组织映射(SOM),并在传感器数据分析等场景中展现应用价值。隐马尔可夫模型则是一种可解释的序列模型,用于从观测数据中推断隐藏状态,广泛应用于语音识别、自然语言处理和生物信息学等领域。文章详细讲解了HMM的核心概念如马尔可夫性质、转移与发射概率,并通过TensorFlow实现了前向算法,展示了其计算观测序列概率的动态规划思想。最后对比了两类方法的应用场景,展望

garlic的博客 186

CodeForces650AWatchmen

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 watchman is loca

菜鸟的自我修养 531

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

Codeforces 650A Watchmen(数学,算法优化)

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 t

Chunzhen的博客 1304

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

650A.Watchmen

. 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 to

willav_v的博客 576

CF650A Watchmen(STL+map)

目录 CF650A Watchmen 1. 手推公式 2.算法 3.优化 4.补充 CF650A Watchmen 只有三个map的一篇题解 1. 手推公式 \(|x2-x1|+|y2-y1|=\sqrt{(x2-x1...

baliu5600的博客 237

Watchmen(排列,去重)

Watchmen Time Limit:3000MS    Memory Limit:262144KB    64bit IO Format:%I64d & %I64u SubmitStatus Description Watchmen are in a danger and Doctor Manhattan together with his friend Danie

昨日明眸 465

Codeforces Round #345 (Div. 2) [Codeforces651]

A Joysticks 贪心 B Beautiful Paintings 模拟 C Watchmen 排序

idealism_xxm的专栏 808

Codeforces650A Watchmen

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 tog

KeyboardPianist的博客 590

Watchmen(Codeforces 650A)

A. Watchmen time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Watchmen are in a dange...

weixin_34087503的博客 145

Watchmen (Codeforces Round #345 (Div. 2) C)

C. 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 t

blanKey的博客 632

Codeforces 650A 数学简单题

题目:http://codeforces.com/problemset/problem/650/A 题意: 给出n个点,问符合和|xi - xj| + |yi - yj|. 这两个公式算出来的两点“距离”相等的点对有几个? 分析: 显然如果上面两个公式相等,那么必须横坐标相等或者纵坐标相等,每次从相等的个数中取出两个的,就是这一相等坐标的排列数,分别按横纵坐标...

210

STL应用---Codeforces-650-A.watchman

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

PrConstantin 1104

CF #651C. Watchmen(map容器)

题目: 给出序列对x , y 判断右边两个式子是否相等 |xi - xj| + |yi - yj|. 分析:对两边式子进行平方运算得 |xi - xj| * |yi - yj|=0.,所以得到xi==xj或yi==yj. 只要枚举这两者出现的情况即可,注意要去重。 数据结构:map,pair#include<bits/stdc++.h> using namespace std

QAQ 511

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

无知的我 1231
上一篇: CodeForces - 631C(103/600)
下一篇: CodeForces 850A(105/600)
NineFailure
博客等级 码龄11年 22粉丝 317原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值