[UVA Live 12931 Common Area]扫描线】的更多相关文章

题意:判断两个多边形是否有面积大于0的公共部分 思路:扫描线基础. #pragma comment(linker, "/STACK:10240000") #include <bits/stdc++.h> using namespace std; #define X first #define Y second #define pb push_back #define mp make_pair #define all(a) (a).begin(), (a).end() #de…
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=16&page=show_problem&problem=1346 Dynamic programming 需要注意的是input里可能含有空行,一行空行也是一个string,所以如果用scanf("%s", string)是不能把空行存进string变量里的.需要用gets或者getli…
Problem C: Longest Common Subsequence Sequence 1: Sequence 2: Given two sequences of characters, print the length of the longest common subsequence of both sequences. For example, the longest common subsequence of the following two sequences: abcdgh…
最长公共子序列,经典问题.算是我的DP开场题吧. dp[i][j]表示到s1的i位置,s2的j位置为止,前面最长公共子序列的长度. 状态转移: dp[i][j] = 0                                       (i == 0 || j == 0) dp[i][j] = dp[i-1][j-1] + 1                   (s1[i] == s2[j]) (此字符相等,说明此时最长公共子序列的长度等于他们之前的LCS(简称)长度加上这个相等的字…
This is the classic LCS problem. Since it only requires you to print the maximum length, the code can be optimized to use only O(m) space (see here). My accepted code is as follows. #include <iostream> #include <string> #include <vector>…
思路:海伦公式, AC代码: #include<bits/stdc++.h> using namespace std; int main() { int n; scanf("%d",&n); double ha, hb, hc, a, b, c; while(~scanf("%lf %lf %lf",&ha,&hb,&hc)) { a = 2.0 / ha; b = 2.0 / hb ; c = 2.0 / hc; if(…
题意:如题,用表达式树来表示一个表达式,且消除公共的部分,即用编号表示.编号 K 定义为表达式第 K 个出现的字符串. 解法:先构造表达式树,给每棵子树用(string,left_son,right_son)-->(哈希值,...,...)编号.由于最多出现4个小写字母,所以可以用27进制数表示,同时也要利用好映射map的count(),和对应的dict[]的编号. 再递归输出表达式,利用编号的定义,看输出编号或字符串. 注意--这里的自定义比较器用的是"显式定义",若是2个键值…
Tell me the area Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1876    Accepted Submission(s): 567 Problem Description     There are two circles in the plane (shown in the below picture), ther…
http://acm.hdu.edu.cn/showproblem.php?pid=1798 Problem Description     There are two circles in the plane (shown in the below picture), there is a common area between the two circles. The problem is easy that you just tell me the common area.   Input…
题目链接 Problem Description     There are two circles in the plane (shown in the below picture), there is a common area between the two circles. The problem is easy that you just tell me the common area.   Input There are many cases. In each case, there…