POJ 2900 Griddy Hobby

Screenshot_2026-11-04-16-26-45-46.jpg 立即下载

Griddy Hobby
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 414 Accepted: 146

Description

Attending a boring weekly session, our professor started drawing on a grid in a page of his calendar. He started at a boundary grid point P; note that P is a corner of one or two grid cells. He drew a diameter of one of those cells and continued on a straight line until reaching point Q on another edge of the grid. Then he started another line from Q, perpendicular to the line PQ until hitting another edge at point R. He kept drawing lines as above, until he could not draw a new line, either because a perpendicular line would not start with a cell diameter or it would fall on an already drawn line. Then he was puzzling how he would be able to count the number of minimal rectangles he has created on the grid. At this time, the chair of the session noticed him and asked him what he was doing. "Sorry, I was designing a problem for the ACM-ICPC Tehran site," he said.

You are to write a program to, given the dimensions R and C of a grid, the coordinates x and y of a point P on one of the edges of the grid, and the direction (up, left), (down, left), (up, right), or (down, right) of the first line, help the professor to find out the number of minimal rectangles.

Input

The input file contains multiple test cases. The first line of the input, contains t, the number of test cases that follow. Each of the following t blocks, describes a test case.

The first line of each block, contains two positive integers R and C, which are the number of horizontal and vertical gridlines, respectively (2 <= R,C <= 1000). The coordinates of the starting point comes on the next line, as two positive integers y and x, (1 <= y <= R, 1 <= x <= C ); for the upper-left point of the grid, we have x = y = 1. The third line of each test case, contains a two-character code which is one of the following:
  • "DR", the first move is in the down-right direction,
  • "DL", the first move is in the down-left direction,
  • "UL", the first move is in the up-left direction,
  • "UR", the first move is in the up-right direction.

Output

For each test case, output one line containing the number of non-overlapping rectangles formed.

Sample Input

2
4 5
2 1
DR
4 5
4 1
UR

Sample Output

1
3

Source

 

/*

Keep fighting.

计算几何题,仔细思考不难发现,所有直线交点(转折点除外,即反射点),所有当前

新生成的直线与其相邻直线外所有直线交点的个数和即为所求,所以在模拟过程中可以

存储所有的直线当处理某一条直线时,只需遍历所有已经生成的直线(其相邻直线除外)

统计交点个数即可。终止条件的判断用了个技巧,每个点都有1,2,3,4四个方向,如果

有哪个点的方向被重复或者到底矩形的四个顶点则访问终止

*/

 

 

 

互联网 Java 工程师进阶知识完全扫盲:涵盖高并发、分布式、高可用、微服务、海量数据处理等领域知识 立即下载

相关推荐

【动态多智能体系统的通信感知编队控制】一种新颖的通信感知编队控制策略,用于动态多智能体系统研究(Matlab代码、Python代码实现)

内容概要:文档名为《Plecs全桥LLC谐振变换器仿真模型.txt》,但其内容并未深入介绍Plecs环境下全桥LLC谐振变换器的具体建模与仿真过程,而是呈现为一份涵盖多领域科研主题的资源列表。文档内容广泛涉及多智能体系统控制、无人机路径规划、电力电子变换器、状态估计、信号处理、优化算法等研究方向,并多次提及Matlab/Simulink、Python等工具的代码实现。整体来看,该文档更像是一份科研项目目录或技术资源索引,重点推介了包括LLC谐振变换器在内的多种控制系统与电力电子仿真模型,但对标题所述核心内容缺乏详尽的技术描述与实现细节。; 适合人群:电力电子、自动化、控制工程、信号处理及多智能体系统等相关领域的研究生、科研人员与工程技术人员。; 使用场景及目标:①为科研工作者提供跨学科的技术方向参考与研究选题灵感;②获取电力系统、无人机控制、信号处理等领域成熟的Matlab/Simulink或Python仿真代码资源,用于算法验证与模型复现。; 阅读建议:建议将此文档作为科研资源导航目录使用,读者可根据自身研究方向筛选感兴趣的主题,并通过文中提供的公众号或网盘链接获取完整的代码、仿真模型与配套资料进行深入学习与实践。

POJ 2098 Ellipse 笔记

给出椭圆(椭圆的轴可能不是垂直的或水平的)上五个点的坐标,求椭圆面积。 

woniupengpeng的专栏 348

产业园区运营负责人如何提升企业技术需求与科研资源的精准匹配效率?.docx

科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。

POJ 2036 I Conduit! 笔记

n段线段,给出线段的端点坐标。重新绘制最少需画多少线段。

woniupengpeng的专栏 360

CATIA CAA 二次开发去除面内开孔

测试模型: 代码说明:以下代码在拓扑级去除Face的内部loop,更改后的Body通过oispBody参数输出。主要使用CATSmartBodyDuplicator拓扑操作实现 HRESULT CAAStarterCmd::RemoveHoleOnFace(CATBody_var &ispBody,CATBody_var &oispBody){ CATLISTP(CATCell)olistFace; ispBody->GetAllCells(olistFace,2); CATF

weixin_45445751的博客 2265

Imputation Methods for scRNA Sequencing Data

越来越多的研究者使用单细胞RNA测序(scRNA-seq)技术来表征单细胞水平的转录图谱。他们用它来研究复杂组织的异质性、转录组动力学和未知生物的多样性。然而,在基因表达模式随机性的scRNA-seq数据中普遍存在许多技术和生物学上的噪音。这些数据通常具有高维、稀疏和大量“dropout”值的特点,并且受批处理效应的影响。scRNA-seq数据中大量的“dropout”值严重掩盖了基因之间的重要关系,阻碍了下游分析。因此,scRNA-seq数据dropout值的估算就显得尤为重要。

qq_34179307的博客 542

POJ 刷题顺序

POJ从简到难(按照AC数目排序)的列表如下,作为小弱的刷题

thestoryofsnow的专栏 31万+

多孔材料吸附性质模拟程序RASPA的离线和在线安装方法

RASPA-2.0是今年美国西北大学教授Randall Q. Snurr等人开发的针对于MC,MD,分子力学优化等用途的程序,相比于之前开发的MUSIC软件,RASPA的功能更加齐全,操作更加简便,可以在MC的吸附过程中考虑骨架的柔性,也可以想MUSIC一样先制作积分格点(music中的map)。 A、离线安装(centos为例): (1)、安装之前要检查一下是否装了automake,

youyno的博客 1万+

poj完整分类

DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  1024   Calendar Game       简单题  1027   Human Gene Functions   简单题  1037   Gridland            简单题  1052   Algernon s Noxious

zhongkeli的专栏 7874

从零开始:手把手教你设计人形机器人锂电池供电系统

人形机器人要像人类一样“活起来”,必须有稳定的“能量血液”——供电系统。本文聚焦锂电池供电系统如何根据机器人功耗选择合适的锂电池参数(容量、电压、放电倍率);如何设计电池管理系统(BMS)保护电池安全;如何解决机器人运动时的“瞬时大电流”供电难题;如何通过硬件电路和代码实现供电系统的监测与控制。用“机器人小助手的能量危机”故事引入锂电池供电系统;拆解锂电池核心参数(容量、电压、放电倍率)和供电系统三大组件(电池组、BMS、电源转换模块);

AI天才研究院 1759

ABAP 平台 SOAUTH2_CLIENT 全面实战:用一套配置,打通 OAuth 2.0 客户端的创建、联调与运维

本文是一份ABAP平台上配置OAuth 2.0客户端的全流程指南,重点介绍新界面SOAUTH2_CLIENT的使用方法。内容涵盖从概念解析到实操步骤,包括四种常见授权方式的选择、证书信任管理、Scope配置以及联调技巧。指南通过两个企业级案例(对接SAP BTP Cloud Integration和SAML 2.0身份联合)展示实际应用场景,并提供了配置清单和伪代码示例。特别强调新界面将客户端配置、令牌测试和校验功能整合的工程化优势,以及与旧事务码OA2C_CONFIG的主要差异。文中多处引用SAP官方文档

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 319

POJ 1127 Jack Straws

 Jack StrawsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 1824 Accepted: 817DescriptionIn the game of Jack Straws, a number of plastic or wooden "st

bobten2008的专栏 2178

RK3576 PCIE接口调试:基于RTL8111HS的网卡驱动移植

检查项方法电源电压复位时序检查设备树 reset-gpios链路速率设备识别lspci -vvv驱动加载。

小灰灰的博客 736

POJ 2079 Triangle

 TriangleTime Limit: 3000MS Memory Limit: 30000KTotal Submissions: 4224 Accepted: 1149DescriptionGiven n distinct points on a plane, your task is to find the tr

bobten2008的专栏 2084

解决宿主机Ping不通虚拟机的问题

在使用虚拟机的过程中,我们常常会遇到宿主机和虚拟机之间无法相互通信的问题。具体来说,我们要查看虚拟机和宿主机的 IP 地址,然后尝试进行 Ping 测试。在某些情况下,我们可能发现 Ping 虚拟机不通,接下来我将分享如何解决这个问题。

howard2005的专栏 7万+

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

POJ 2074 Line of Sight

 Line of SightTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 1406 Accepted: 423DescriptionAn architect is very proud of his new home and wants to be

bobten2008的专栏 1732

计算机控制技术及应用

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

POJ 1673 EXOCENTER OF A TRIANGLE

 EXOCENTER OF A TRIANGLETime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 1853 Accepted: 682DescriptionGiven a triangle ABC, the Extriangles of ABC are co

bobten2008的专栏 1307

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

POJ 2036 I Conduit!

 I Conduit!Time Limit: 2000MS Memory Limit: 30000KTotal Submissions: 1313 Accepted: 245DescriptionIrv Kenneth Diggit works for a company that excavates trenches

bobten2008的专栏 1293

POJ 1244 Slots of Fun

 Slots of FunTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 748 Accepted: 441DescriptionThe International Betting Machine company has just issued a n

bobten2008的专栏 1017

POJ 1899 Farmer Bill's Problem

 Farmer Bills ProblemTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 2159 Accepted: 514DescriptionIt is rumored that the planet Earth is often visited

bobten2008的专栏 994

POJ 1675 Happy Birthday

 Happy Birthday!Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 3352 Accepted: 791DescriptionThere are three berries on a round birthday cake. You a

bobten2008的专栏 960

POJ 1113 WALL

 WallTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 13254 Accepted: 4217DescriptionOnce upon a time there was a greedy King who ordered his chief Arc

bobten2008的专栏 949

POJ 1873 The Fortified Forest

The Fortified ForestTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 1894 Accepted: 561DescriptionOnce upon a time, in a faraway land, there lived a king.

bobten2008的专栏 897

POJ 1696 Space Ant

 Space AntTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 834 Accepted: 542DescriptionThe most exciting space discovery occurred at the end of the 20t

bobten2008的专栏 755
上一篇: 怎样写一个拼写检查器 Peter Norvig 翻译: Eric You XU
下一篇: POJ 2901 Hotel
bobten2008
博客等级 码龄18年 153粉丝 157原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值