题意:给个棋盘,你可以在棋盘的边缘处放2个蓝色棋子2个黄色棋子,问连接2组同色棋子的最小代价,如果线路交叉,输-1. 析:交叉么,可以把它们看成是两条线段,然后如果相交就是不行的,但是有几种特殊情况,比如都在同一行或同一列,要特殊考虑这种情况. 1122,1212,2211,2121,1221,2112.这是几种特殊的,然后其他的就可以用判交叉来算了,然后最短路就是横纵坐标相减的绝对值加2. 代码如下: #pragma comment(linker, "/STACK:1024000000,102…
                                                      That Nice Euler Circuit Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 1977   Accepted: 626 Description Little Joey invented a scrabble machine that he called Euler, after the great…
题意:从左至右给你n个正方形的边长,接着这些正方形都按照旋转45度以一角为底放置坐标轴上,最左边的正方形左端点抵住y轴,后面的正方形依次紧贴前面所有正方形放置,问从上方向下看去,有哪些正方形是可以被看到的(如图) 题解:首先找到每个正方形左右端点的坐标转化为一条线段,接着寻找哪些线段被其他某些条线段覆盖,那这些被覆盖的线段就不能被看到了 寻找被覆盖的线段利用区间贪心,我们按照左端点升序.左端点相同右端点降序排序,则左端点一定被前面的线段覆盖,接着对于右端点使用单调栈的思想寻找可以看到的线段就好…
You are to write a program that has to decide whether a given line segment intersects a given rectangle. An example: line: start point: (4,9) end point: (11,2) rectangle: left-top: (1,5) right-bottom: (7,1)  Figure 1: Line segment does not intersect…
链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1010 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=29328#problem/B Area Time Limit: 2 Seconds       Memory Limit: 65536 KB       Special Judge Jerry, a middle school student, ad…
Jack Straws In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table and players try to remove them one-by-one without disturbing the other straws. Here, we are only concerned with if various pairs of straws are…
题目没什么 只是线段相交稍微写的好看了点 Pipe Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1252    Accepted Submission(s): 481 Problem Description 经过激烈的争夺,Lele终于把那块地从Yueyue的手里抢了回来.接下来,Lele要开始建造他的灌溉系统. 通过咨询Lele的…
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7847    Accepted Submission(s): 3834 Problem Description Many geometry(几何)problems were designed in the ACM/…
题目链接 关于判断线段相交,具体算法见 点击打开链接 ,先进行快速排斥试验,若不能判断出两个线段不相交,再进行跨立试验. //吐槽1,long long 会溢出... //吐槽2,只进行跨立试验的虽然也可以ac,然而并不能解决两线段共直线且不相交的情况 #include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include&l…
1264 线段相交 给出平面上两条线段的两个端点,判断这两条线段是否相交(有一个公共点或有部分重合认为相交). 如果相交,输出"Yes",否则输出"No".   输入 第1行:一个数T,表示输入的测试数量(1 <= T <= 1000) 第2 - T + 1行:每行8个数,x1,y1,x2,y2,x3,y3,x4,y4.(-10^8 <= xi, yi <= 10^8) (直线1的两个端点为x1,y1 | x2, y2,直线2的两个端点为x3…