Codeforces 651C - Watchmen

Mann-Kendall检验全解析:从原理到11种变体及Python实现 本文全面解析Mann-Kendall检验,从基础原理到应对自相关、季节性等复杂数据的11种关键变体,如Hamed-Rao修正、季节性MK和趋势自由预白化(TFPW)。详细阐述各方法的适用场景与数学原理,并提供完整的Python实战代码,帮助研究者针对不同数据特性选择最稳健的趋势分析方法。 阅读详情

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

Examples
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


/*
Codeforces 651C - Watchmen

给你很多组a,b  然后通过两种计算方法判断答案是否相同
1.  |xi-xj|+|yi-yj|
2. sqrt((xi-xj)*(xi-xj) + (yi-yj)*(yi-yj))

然后发现只有当xi = xj 或 yi = yj时答案相同
但同时要排除(xi,yi)=(xj,yj)的情况

hhh-2016-03-07 17:04:24
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
using namespace std;
typedef long long ll;
typedef long double ld;
#define lson (i<<1)
#define rson ((i<<1)|1)
const int maxn = 10010;

ll a;
ll b;
map<ll,ll> mp1;
map<ll,ll> mp2;
map< pair<ll,ll>,ll > mp;
int main()
{
    int T,n,m;
    while(scanf("%d",&n) != EOF)
    {
        ll ans = 0;
        ll num = 0;
        mp1.clear();
        mp2.clear();
        mp.clear();
        for(int i = 1; i <= n; i++)
        {
            scanf("%I64d%I64d",&a,&b);

            num += mp[ make_pair(a,b)];
            mp[ make_pair(a,b)] ++;

            if(mp1.find(a) == mp1.end())
                mp1[a] = 1;
            else
            {
                ans += mp1[a];
                mp1[a]++;
            }

            if(mp2.find(b) == mp2.end())
                mp2[b] = 1;
            else
            {
                ans += mp2[b];
                mp2[b]++;
            }
        }
        printf("%I64d\n",(ll)ans-num);
    }
    return 0;
}



生成模型实战 | 基于Transformer生成音乐 本文介绍了基于Transformer架构的音乐生成方法,将音乐视为一系列事件序列进行处理。与将音乐表示为多维图像的MuseGAN不同,该方法使用类似GPT的仅解码器模型,基于先前事件预测下一个音乐事件。模型使用MIDI格式的钢琴音乐数据,通过分词处理将音符转换为note-on、note-off、time-shift和velocity四种事件类型,共388个独特词元,映射为索引序列后输入网络。训练完成后,可通过调整温度参数控制生成音乐的新颖性,从而创作出风格类似训练数据且连贯逼真的音乐作品。 阅读详情

相关推荐

PV-RCNN实战:如何在KITTI数据集上实现3D目标检测(附完整代码解析)

本文提供了在KITTI数据集上实战PV-RCNN 3D目标检测的完整指南,涵盖环境配置、数据预处理、模型训练与评估全流程。通过详细的代码解析和调参技巧,帮助读者掌握这一融合点与体素优势的经典3D目标检测模型,并实现从理论到实践的跨越。

weixin_29098391的博客 403

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

告别Keil4!手把手教你用Keil C51 V9.61编译51单片机代码(附最新激活方法)

本文详细介绍了Keil C51 V9.61在51单片机开发中的全栈升级指南,包括编译速度提升、调试器性能优化和现代开发支持等核心优势。通过智能安装方案、项目迁移实战和新特性深度应用,帮助开发者告别Keil4,大幅提升开发效率。附有最新激活方法和实用技巧,适用于嵌入式开发工程师。

weixin_26886855的博客 419

Codeforces 651C Watchmen【模拟】

题意: 求欧几里得距离与曼哈顿距离相等的组数。 分析: 化简后得到xi=xj||yi=yj,即为求x相等 + y相等 - x与y均相等。 代码: #include<iostream> #include<algorithm> using namespace std; const int maxn = 1000000 + 5; typ...

An55511的博客 232

日志异常检测详细整理,看这一篇就够了(附各项目代码链接)

对于不用的日志键,用它们的参数值向量训练一个参数值异常检测模型来检测有这些参数值反映的系统性能异常。与标准的GAN框架一样,D和G的参数是基于D的输出来更新的,因此鉴别器D可以被训练为尽可能敏感地将正确的标签分配给真实和虚假序列,而生成器将被训练为尽可能聪明地在经过足够多轮的迭代后欺骗鉴别器,即误导D将真实标签分配给虚假序列。LR:逻辑回归是有监督的模型,将处理后的特征矩阵以及标记作为模型的输入,得到训练后的模型,用此模型预测新出现的特征向量,以此判断特征向量是否为异常的,进而判断日志异常。

qq_20368489的博客 1万+

PCB线路板的制作工艺流程分享!2021-08-21

Pcb板制作工艺流程:开料-钻孔-沉铜-压膜-曝光-显影-电铜-电锡-退膜-蚀刻-退锡-光学检测-印阻焊油-阻焊曝光、显影-字符-表面处理-成型-电测-终检-抽测-包装。具体如下:1、开料(CUT) 将原始的覆铜板切割成可以用在生产线上制作的板子过程2、钻孔 使PCB板层间产生通孔,以达到连通层间的目的。 3、沉铜 经过钻孔后的线路板在沉铜缸内会发生氧化还原反应,形成铜层对孔进行孔金属化,使原来绝缘的基材表面沉积上铜,达到层间电性相通。 4、压膜 压膜后的PCB板上面压了一层蓝色的干膜, 干膜是一个载体

jdbpcb88的博客 3245

CodeForces 651C Watchmen

F - Watchmen Time Limit:3000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 651C Description Watchmen are in a danger and Doctor Manhat

Yesterday You Said Tomorrow. 1669

基于Openrouter的API调用免费大模型

Openrouter 是一个 AI 模型聚合平台,整合了全球 200 多种主流 AI 模型,包括 GPT-4、Claude、Gemini 等,以及国产通义千问、DeepSeek 等。其核心优势是统一的 API 设计,开发者仅需少量代码即可与多个模型交互,还支持自动路由与回退机制。用户可通过 OpenAI SDK 或 LangChain 调用 Openrouter 中的模型。

MurphyStar的博客 6199

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 1099

YOLO11-Seg优化:卷积变体系列篇 | 动态蛇形卷积(Dynamic Snake Convolution) | ICCV2023

动态蛇形卷积(Dynamic Snake Convolution),增强微小特征提取能力,引入到YOLO11-Seg,与C3k2结合实现二次创新

会AI的学姐 368

18.EC实战 新建项目工程并配置各个引脚的工作方式(持续更新)

本博文介绍了从零开始新建EC工程及对各个引脚进行了工作模式的初始化配置

qq_30135687的博客 1731

【CodeForces】[651C]Watchmen

由题意可知满足条件的点 必然是x相同或者y相同 (可有等式化简得到)麻烦的地方在于存在 相同的点 所以计算时需要去除重复这一题写了有断断续续几个小时 所以思路有点混乱 到后面有点方 所以导致忘记了一些小技巧 然后越方越错 好在最后怼出来了也是一直想着避免加重 事实上换种思路 也可以想做先加上 然后去除重复的最后需要注意的是 数据类型要用__int64

BoilTask Talk Show 574

UFS软件分区介绍

本文主要介绍了ufs软件分区管理的概况,能够使大家对软件分区有个大体的认识

肥匪斐's blogs 1万+

【Codeforces】-651C -Watchmen

点击打开题目 C. Watchmen time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Watchmen are in a dange

Bear1998的博客 510

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

codeforces 651C 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 poi...

aoanping0730的博客 188

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

CodeForces 651 C Watchmen

CodeForces 651 C Watchmen

Dacc123的博客 765

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

欧姆龙NJ/NX PLC的FINS通信与Node-RED可视化实战指南

在工业自动化与物联网平台快速融合的今天,产线数据采集已从简单的PLC监控演变为连接MES、SCADA与云端可视化系统的关键环节。要实现PLC数据的高效读取,理解底层通信协议是基础。FINS协议作为欧姆龙定义的工业以太网标准,以结构清晰、报文直观且不依赖额外授权为特点,成为连接NJ/NX系列PLC与上位机的主流方式。通过FINS/TCP报文逐字段拆解,开发者既能手动构造读写指令,也能借助Node-RED这一开源流编排工具,快速搭建实时仪表盘与数据推送链路。无论是面向本地的可视化大屏,还是通过MQTT将数据推送

weixin_34246551的博客 282

【CodeForces - 651C 】Watchmen(map)

Watchmen 直接上中文 Descriptions: 钟表匠们的好基友马医生和蛋蛋现在要执行拯救表匠们的任务。在平面内一共有n个表匠,第i个表匠的位置为(xi, yi). 他们需要安排一个任务计划,但是确发现了一些问题很难解决。马医生从第i个表匠到第j个表匠所需要的时间为|xi - xj| + |yi - yj|。然而蛋蛋所需要的时间为 要想成功完成任务,必须保证两人从第i个表匠出发...

weixin_30477293的博客 115

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的博客 458

Codeforces 651 C Watchmen【思维】

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 together wi

mengxiang000000 555

CodeForces 651C Watchmen map

Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There arenwatchmen on a plane, thei-th watchman is located at point(x...

weixin_30820077的博客 79
上一篇: hdu 4777 树状数组+合数分解
下一篇: hdu 5641 BestCoder Round #75
Tyuio28
博客等级 码龄11年 12粉丝 279原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值