您当前的位置: 首页 > 

先求一个导

暂无认证

  • 1浏览

    0关注

    291博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

codeforces 775-div2 C(摆大烂)

先求一个导 发布时间:2022-03-06 22:53:36 ,浏览量:1

题目 题意: 给定n*m的矩阵,矩阵每个位置有对应的颜色。求同种颜色任意两对坐标之间的曼哈顿距离之和。dis(x1,y1,x2,y2) = abs(x1 - x2) + abs(y1 - y2) 思路: x和y无关,可以分开统计贡献。把颜色col对应的所有点的x、y坐标分别存起来,之后sort一下。 在这里插入图片描述

时间复杂度: (tlogt, t = nm) 代码:

// Problem: C. Weird Sum
// Contest: Codeforces - Codeforces Round #775 (Div. 2, based on Moscow Open Olympiad in Informatics)
// URL: https://codeforces.com/contest/1649/problem/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define OldTomato ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define fir(i,a,b) for(int i=a;i            
关注
打赏
1662037414
查看更多评论
0.0401s