Bishops Alliance

Codesys电子凸轮实战:从机械替代到虚轴设计的5个关键步骤 本文详细介绍了Codesys电子凸轮技术在运动控制领域的实战应用,从机械替代到虚轴设计的5个关键步骤。通过电子凸轮技术,操作员可以快速调整切割模式,显著提升产线效率。文章还探讨了虚轴架构、CAM表设计、动态耦合技巧及调试避坑指南,为工业自动化领域提供了实用的解决方案。 阅读详情

F. Bishops Alliance
time limit per test
9 seconds
memory limit per test
256 megabytes
input
bishops.in
output
standard output

Chessforces is coming into a great war. The Knights Alliance is aiming to attack the Bishops Alliance land, it is up to you to help bishops defending their homeland.

In order to defeat the attacking knights, bishops want to make their defense line as big as possible. Defense line is a set of bishops on the chessboard where each pair of bishops in this set satisfies OK relation. OK relation between bishop i and bishop j is satisfied if they are on the same diagonal and the number of squares on the diagonal path between i and j is at least equal to pi2 + pj2 + C, where pk is privacy distance for bishop k and it is given for each bishop on the board, C is a given constant. Note that the path between two bishops includes both bishops squares.

Given the coordinates of each bishop on the chessboard, help them to find the defense line with maximum number of bishops.

Input

First line contains number of test cases T. Each test case contains one line with (0 < n ≤ 105) size of the chessboard edge, (0 < m ≤ 105) number of bishops and the constant (0 ≤ C ≤ 105) then m line follows, the ith line of them contains three integers: (1 ≤ ri, ci, pi ≤ n) where (ri,ci) is row number and column number of the ith bishop and pi is the privacy of the ith bishop.

Output

Print a single integer, the size of the defense line with maximum number of bishops.

Example
input
1
8 5 2
7 7 1
4 4 1
3 5 1
2 6 2
4 8 1
output
2
Note

Large I/O files. Please consider using fast input/output methods.

First test case explanation, columns go from left to right and rows go up to bottom, bishops labeled with borders are included in the defense line.



先把每一对角线上的点都记录下来,然后可以把每个点看为一个线段区间,这个区间的范围也就是[ xi- ( pi*pi+c/2+0.5 )  ,  xi + ( pi*pi+c/2+0.5 ) ]  这样只要两个区间不相交,就可以保证满足“OK relation”

然后就是对于每条对角线贪心求最大不相交区间覆盖



调了半天看了题解才知道要“

input
bishops.in"。。。。。。。。。。freopen("bishops.in","r",stdin); 

并且大牛们用的区间都是[ xi- ( pi*pi)  ,  xi + ( pi*pi) ]  因为那些项都是常数,可以在贪心时判断条件稍微改一下

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<functional>
#include<vector>
using namespace std;
struct node
{
	int x;
	double p;
};
double c;
int cmp(node a,node b)
{
	double s1=a.p+c/2-0.5,s2=b.p+c/2-0.5;
	if(1.0*a.x-s1==1.0*b.x-s2)
	return a.x+s1<b.x+s2;
	return 1.0*a.x-s1<1.0*b.x-s2;
}

vector<node>w[200005],v[200005];
int main()
{
	freopen("bishops.in","r",stdin);  
	int T,t,n,m,i,ans,j,x,y;
	double p;
	node point;
	scanf("%d",&T);
	while(T--)
	{
		ans=0;
		scanf("%d %d %lf",&n,&m,&c);
		for(i=0;i<=2*n+1;i++)
		{
			w[i].clear();
			v[i].clear();
		}
		for(i=0;i<m;i++)
		{
			scanf("%d %d %lf",&x,&y,&p);
			p*=p;
			point.x=x;
			point.p=p;
			w[x-y+n].push_back(point);
			v[x+y-1].push_back(point);	
		}

		for(i=0;i<=2*n;i++)
		{
			sort(w[i].begin(),w[i].end(),cmp);
			int t=0;
			node po;
			double ri;
			for(j=0;j<w[i].size();j++)
			{
				po=w[i][j];
				double s=po.p+c*1.0/2-0.5;
				if(j==0)
				{
					t=1;
					ri=po.x+s;
					continue;
				}
				if(ri<=1.0*po.x-s)
				{
					t++;
					ri=po.x+s;
				}
				else
				{
					ri=min(ri,po.x+s);
				}	
			}
			ans=max(ans,t);
		}
		//其实完全可以用三维vector嵌套一层循环,代码比较简练
		for(i=0;i<=2*n;i++)
		{
			sort(v[i].begin(),v[i].end(),cmp);
			int t=0;
			node po;
			double ri;
			for(j=0;j<v[i].size();j++)
			{
				po=v[i][j];
				double s=po.p+c*1.0/2-0.5;
				if(j==0)
				{
					t=1;
					ri=po.x+s;
					continue;
				}
				if(ri<=1.0*po.x-s)
				{
					t++;
					ri=po.x+s;
				}
				else
				{
					ri=min(ri,po.x+s);
				}	
			}
			ans=max(ans,t);
		}
		
		printf("%d\n",ans);
	}
	return 0;
}



用 RFC Destination 打通 VS Code 与 ABAP 后端,ABAP 开发连接不只是登录那么简单 本文重点介绍了在VS Code中配置ABAP开发环境时建立RFC destination连接的关键细节。文章指出:1. RFC destination是连接前端开发工具与ABAP后端的核心配置,包含系统类型、客户端、用户名等关键信息;2. 连接方式的选择(RFC/HTTP)由产品形态决定,On-Premise和Private Edition使用RFC,而BTP和Public Cloud使用HTTP;3. 连接创建后需要通过添加工作区文件夹来展示开发对象;4. RFC连接涉及网络可达性、身份认证和开发权限三个 阅读详情

相关推荐

告别‘小爱同学’:用ESP32-S3和esp-sr SDK,从零打造一个离线语音助手(含完整代码)

本文详细介绍了如何利用ESP32-S3芯片和esp-sr SDK从零构建一个离线语音助手,涵盖硬件选型、声学设计、SDK配置及低功耗优化等关键步骤。通过实战案例和完整代码,帮助开发者实现自定义唤醒词和命令词,打造低成本、高隐私的本地语音控制解决方案。

weixin_29041195的博客 371

Gym 101147F Bishops Alliance 题解

Gym 101147F题解

DarkoDu的博客 488

单细胞数据互转实战:从Scanpy的h5ad到Seurat对象的四种高效方法

本文针对单细胞数据分析中Scanpy的h5ad格式与Seurat对象互转的常见难题,详细对比了SeuratDisk、anndataR、schard和sceasy四种高效转换方法。文章从实战出发,剖析了每种方法的原理、操作流程、优缺点及避坑指南,并提供了清晰的选型策略,帮助用户根据数据特点选择最佳方案,实现跨平台数据的无缝衔接。

weixin_29099217的博客 446

Bishops Alliance Gym - 101147F

https://cn.vjudge.net/problem/Gym-101147F i-j>=pi^2+pj^2+C => i-pi^2>=j+pj^2+C-1; 最长上升子序列,树状数组维护; #include <iostream> #include <cstring> #include <queue> #include...

newhonor 225

实现电脑同时上内网和外网(或通过外网访问到该电脑通过该电脑访问内网)

一、需求描述 目前使用的公司网络只能够上内网,但是又有上外网查资料的需求: ①想要实现电脑既能上内网的同时也可以上外网; ②想要使用其他外网电脑使用外网连接到该电脑,通过该电脑访问内部的网络内容。 二、准备内容 电脑必须具备两个网卡,即:可以同时连接内网和外网(比如我的笔记本就可以:使用网线连接笔记本网口与内网通讯,使用WIFI连接手机热点访问外部网络); 注意:如果只有一个网口,可以另外购买USB的无线网卡来实现上网卡。 三、实现电脑同时上内网和外网的操作步骤 3.1、网络拓扑图 ..

提供C#相关开发 、云计算、运维测试、网络安全相关技术分享与服务,有意向可联系。 2万+

AMDGPU驱动中Doorbell与Event机制简要对比

摘要:AMDGpu驱动中,Doorbell和Event是两种异步通知机制。Doorbell是CPU→GPU的单向硬件通知,通过写MMIO寄存器触发GPU拉取任务,延迟低且无需内核介入,适用于队列任务提交。Event是GPU→CPU的双向同步通知,基于中断和内核事件对象,支持阻塞等待,用于任务完成或异常上报。核心区别在于方向、用途和实现方式:Doorbell侧重任务触发,Event侧重状态反馈。两者配合实现高效的任务下发与完成通知流程。

图形/计算GPU的驱动与虚拟化技术分享园地 1852

gym101147 Bishops Alliance

#include using namespace std; typedef long long ll; const int maxn = 100010; struct node{ int x;shuzhuang ll p; node(int x,ll p):x(x),p(p){} node(){} bool operator<(const node

Green_Days 552

卡尔曼滤波器中的Q,R

对于系统状态的估计(滤波结果)所使用的信息来源于两个方面,一个是对系统状态演变模型的了解,包括系统转移矩阵和输入控制矩阵,输入孔质量等,另一方面来自于对系统状态的观测量。从上面公式来看,真正所要滤波得到的结果来自于公式(4)中的系统状态估计值x的某些分量,公式(4)的结果是由公式(1)所得到的状态预测值和来自观测量y计算得到的。所以,在不同算法中,R, Q的取值根据反应的不同量纲,可以有很大的变化,但它们的比值会决定了滤波值应该更多来自于系统模型演化的信息,还是来自于观察信号信息。

qq_43416206的博客 500

GYM 101147 F.Bishops Alliance(dp+BIT)

Description 一个棋盘,上面有一些棋子,第i个棋子有一个p[i]值,现在要选择在同一条对角线上的某些棋子,使得对任意两个棋子i和j,i到j之间所隔格子数不小于pi^2+pj^2+c,其中c是一给定常数,问最多可以选多少个棋子 Input 第一行一整数T表示用例组数,每组用例首先输入三个整数n,m,c分别表示棋盘规格,棋子数量和常数c,之后m行每行三个整数xi,yi,pi表示第i个棋子

ZSQ 565

Qt垂直滚动条QVerticalScrollBar详解:从基础到实战的控件开发指南

本文系统解析Qt中QVerticalScrollBar的用法,从基础概念到进阶技巧。主要内容包括:1)基础认知:介绍其继承关系、作用及典型应用场景;2)核心用法:创建方法、关键属性配置和信号槽连接;3)进阶技巧:自定义样式表美化外观,以及与自定义内容区域的联动实现;4)实战注意事项,如避免循环触发和高DPI适配等。文章强调掌握QVerticalScrollBar对提升Qt滚动类功能开发效率的重要性,并建议通过自定义文本编辑器实践巩固知识点。

专注现代C++实战,从核心语法到高性能编程,助力开发者深入掌握系统级编程精髓。 758

YOLOv10 的损失函数解析

YOLOv10 在 YOLO 系列的演进中进一步优化了任务解耦与动态平衡策略,通过 ​多模态损失融合、自适应样本分配 和 ​轻量化设计,显著提升了检测精度与推理效率。

浩瀚之水的专栏 1378

CodeForces Gym101147F Bishops Alliance

2016-2017 ACM-ICPC, Egyptian Collegiate Programming Contest (ECPC 16)

Tooc0ld 293

内容创作全流程自动化:OpenClaw+大模型搞定选题+写稿+多平台发布

本文介绍了一套基于OpenClaw的全自动化内容创作流水线方案,帮助垂直领域创作者摆脱重复劳动。该方案将内容生产拆解为选题生成、内容撰写、格式适配、多平台发布四个模块,通过工作流引擎串联执行。系统能自动采集热榜生成选题、调用大模型撰写结构化内容、适配不同平台格式要求,并通过API+浏览器自动化实现多平台发布,全程只需人工最终审核。作者分享了各模块的实现细节,包括热榜采集、内容结构化生成、Markdown转换和发布策略,并提供了工作流编排方法。这套方案能为创作者每天节省约3小时,同时保证内容质量和发布效率。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 49

Gym 101147F Bishops Alliance (树状数组+DP)

题目链接:http://codeforces.com/gym/101147/problem/F #include&lt;bits/stdc++.h&gt; using namespace std; #define debug puts("YES"); #define rep(x,y,z) for(int (x)=(y);(x)&lt;(z);(x)++) #define ll long lon...

满月照亮的路 231

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

Bishops Alliance—— 最大上升子序列

原题链接:http://codeforces.com/gym/101147/problem/F 题意:n*n的棋盘,给m个主教的坐标及其私有距离p,以及常数C,求位于同一对角线上满足条件:dist(i, j) >= p[i]^2 + p[j]^2 + C 的主教集合的元素个数最大值。 解题思路: 上述条件可以等价为:   d(j) - d(i) +1 >= p[i...

weixin_30493401的博客 140

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

GYM - 101147 F.Bishops Alliance

题意:   一个n*n的棋盘,有m个主教。每个主教都有自己的权值p。给出一个值C,在棋盘中找到一个最大点集。这个点集中的点在同一条对角线上且对于点集中任意两点(i,j),i和j之间的主教数(包括i,j)不小于pi^2+pj^2+C。 题解:   对角线有2个方向,每个方向有2*n-1条对角线。一共时4*n-2条。每个点都在2条对角线上。   对于在同一对角线上的点(i,j)若满足i-j+1...

weixin_30312557的博客 148

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

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

Codeforces Round #382 (Div. 2)A到D题 A. Ostap and //B. Urbanization//C. Tennis Championship//D. Taxes

A. Ostap and Grasshopper time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output On the way to Rio de Janeiro Ostap

jerans的博客 1287

Gym - 101128C Canvas Painting 逆向思维

https://odzkskevi.qnssl.com/3699857ff0a17d77d1099699cdf4da13?v=1490503337 刚开始读错题意,以为是不变序列,就想着区间dp但数据量肯定会t,,,没想到什么优化方法就放下了,后来队员发现序列是可变的。。。。任意的。。。。。 想着先排序在布拉布拉布拉,一直都没有逆向思维想到哈夫曼。只怪数据结构没认真听啊。。。。 想到哈夫

jerans的博客 945

CodeForces - 361D Levko and Array二分加dp

D. Levko and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Levko has an array that consists of inte

jerans的博客 840

Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) C Fountains 乱搞

C. Fountains time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Arkady plays Gardenscapes a lot. Arkady wants

jerans的博客 810

codeforces 8VC Venture Cup 2017 - Elimination Round D PolandBall and Polygon

D. PolandBall and Polygon time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output PolandBall has such a convex poly

jerans的博客 726

B. The Meeting Place Cannot Be Changed

B. The Meeting Place Cannot Be Changed time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output The main road in Byt

jerans的博客 695

Codeforces Round #380 (Div. 2,Based on Technocup 2017 - Elimination Round 2)C - Road to Cine//

C. Road to Cinema time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya is currently at a car rental service

jerans的博客 684

Beautiful numbers CodeForces - 55D 数位dp

D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Volodya is an odd boy and his taste is

jerans的博客 676

Codeforces Round #423 (Div. 2) C. String Reconstruction思维 D. High Load 构造

C:http://codeforces.com/contest/828/problem/C 题意:有一个字符串,你知道他的一些子串所在的位置,求符合条件的字典序最小的原串 因为已知的数据较大,还存在较多重复的部分,直接暴力不可行 可以记录原串每个位置的下一个没确定出来的字符的位置(记住next【i】),优化后可以过,时间较长 #include #define eps 1e-9 #defin

jerans的博客 672

Codeforces Round #410 (Div. 2) C. Mike and gcd problem 贪心

C. Mike and gcd problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has a sequence A = [a1, a2, ..

jerans的博客 662
上一篇: 100篇!!
下一篇: Codeforces Round #403 (Div. 2) C. Andryusha and Colored Balloons dfs(树)
jerans
博客等级 码龄10年 54粉丝 255原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值