IOI1998 hdu1828 poj1177 Picture】的更多相关文章

写了一发扫描线竟然狂WA不止,hdu死活过不了,poj和当时IOI的数据(还花了我1dsdn积分..)都过了. 然后看到谋篇blog里有评论,把数据拿下来发现WA了. 数据是 20 0 1 11 0 2 1就是有一条边贴着了,这个时候应该先加入新的边再删除,否则会算重. 另外,线段树不用清零哦. //#include<bits/stdc++.h> #include<cstdio> #include<cstring> #include<cstdlib> #in…
[POJ1177]Picture 试题描述 A number of rectangular posters, photographs and other pictures of the same shape are pasted on a wall. Their sides are all vertical or horizontal. Each rectangle can be partially or totally covered by the others. The length of…
地址:http://poj.org/problem?id=1177 题目: Picture Time Limit: 2000MS   Memory Limit: 10000K Total Submissions: 12905   Accepted: 6817 Description A number of rectangular posters, photographs and other pictures of the same shape are pasted on a wall. Thei…
题目链接:https://vjudge.net/problem/POJ-1177 A number of rectangular posters, photographs and other pictures of the same shape are pasted on a wall. Their sides are all vertical or horizontal. Each rectangle can be partially or totally covered by the oth…
1845: [Cqoi2005] 三角形面积并 Time Limit: 3 Sec  Memory Limit: 64 MBSubmit: 1664  Solved: 443[Submit][Status][Discuss] Description 给出n个三角形,求它们并的面积. Input 第一行为n(N < = 100), 即三角形的个数 以下n行,每行6个整数x1, y1, x2, y2, x3, y3,代表三角形的顶点坐标.坐标均为不超过10 ^ 6的实数,输入数据保留1位小数 Out…
求最终的覆盖图形周长,写这种代码应该短而精确,差的比较远 /* Problem: 1177 User: 96655 Memory: 348K Time: 32MS Language: C++ Result: Accepted */ #include<iostream> #include<stdio.h> #include<stdlib.h> #include<math.h> #include <algorithm> using namespace…
题目链接:http://poj.org/problem?id=1177 比矩形面积并麻烦点,需要更新竖边的条数(平行于x轴扫描)..求横边的时候,保存上一个结果,加上当前长度与上一个结果差的绝对值就行了... //STATUS:C++_AC_32MS_1416KB #include <functional> #include <algorithm> #include <iostream> //#include <ext/rope> #include <…
题意如图 题解:这题非常类似与矩形面积并,也是维护一个被覆盖了一次以上的线段总长. 但是周长要算新出现的,所以每次都要和上一次做差求绝对值. x轴做一遍,y轴做一遍. 但是有个问题:矩形边界重合的时候的处理.举个例子,在处理x轴的时候: 怎么处理呢?我们在对y排序的时候把下边界(下边界+1,上边界-1)排在上边界前面,这样做就不会重复算了. #include<cstdio> #include<cstdlib> #include<cstring> #include<…
浅谈树状数组与线段树:https://www.cnblogs.com/AKMer/p/9946944.html 题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1828 扫描线求周长.如果你不知道什么是扫描线可以先去做这题:https://www.cnblogs.com/AKMer/p/9951300.html 每次扫描线上变化的长度就是周长的一部分.横着做一遍竖着做一遍就行了. 如果两条边\(pos\)相同应该先加边后删边,否则重叠部分会多算.…
http://poj.org/problem?id=1177 (题目链接) 题意 求矩形周长并. Solution 转自:http://www.cnblogs.com/Booble/archive/2010/10/10/1847163.html 先看图: 为了解决这个问题 我们先把一坨一坨的矩形 进行矩形切割: 我们考虑周长由哪些部分构成 其中,红线是需要统计入周长的竖边,绿线是需要统计入周长的横边 我们称两条蓝线之间的部分为统计区间 我们需要依次统计从左到右的统计区间内的需要计数的矩形边,累加…
问题来源:IOI1998 D2T1 题意:就是在一个平面内给出n个矩形,叫你计算将这些矩形合并以后,新图形的周长. 例如: 上图是原本的矩形们 ---------->合并后的图形 解题思路:拿一条扫描线横着扫一次,遇到左边的边就在这条扫描线上+1,遇到右边的边就在这条扫描线上-1,在边被扫到的时候计算一下线上为0的个数即可. 因为如果只是单纯的For循环累加,时间会爆,所以我们采用线段树来存这条扫描线的状态优化效率即可.然后竖着再做同样的事做一遍. 时间效率应该是O(kn)(k是常数). 附代码…
Picture Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5516    Accepted Submission(s): 2636 Problem Description A number of rectangular posters, photographs and other pictures of the same shape…
Picture Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6332    Accepted Submission(s): 2951 Problem Description A number of rectangular posters, photographs and other pictures of the same shape…
题意:给定n个矩形,求他们的并的周长 n<=5e3,abs(x[i])<=1e4 思路:From https://www.cnblogs.com/kuangbin/archive/2013/04/10/3013437.html 真实“线段”树 #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<iostream> #include&l…
Picture Time Limit: 2000MS   Memory Limit: 10000K Total Submissions: 12265   Accepted: 6484 Description A number of rectangular posters, photographs and other pictures of the same shape are pasted on a wall. Their sides are all vertical or horizontal…
题目大意:给若干个矩形,求轮廓边长. 题目分析:与求面积类似.按从下往上扫描,仍然是底边添加,上边删除.但要同时维护竖边的数目,每次扫描对答案的贡献为扫描线上总覆盖长度的变化量加上竖边的增量.总覆盖长度的变化为正说明下轮廓增加,为负以为着碰到了上轮廓增加. 代码如下: # include<bits/stdc++.h> using namespace std; # define mid (l+(r-l)/2) # define LL long long const int N=5000; str…
Description 在一个平面上放置一些矩形,所有的边都为垂直或水平.每个矩形可以被其它矩形部分或完全遮盖,所有矩形合并成区域的边界周长称为轮廓周长. 要求:计算轮廓周长. 数据规模: 0≤矩形数目<5000: 坐标数值为整数,范围是[-10000,10000]. Input 第一横列是墙上所贴的长方形总数.之后每一横列是一个长方形的左下角与右上角的整数坐标.个各坐标的x值在前,y值在后. Output 应有一非负整数,即为长方形覆盖图形的总周长 Sample Input 7 -15 0 5…
http://acm.hdu.edu.cn/showproblem.php?pid=1828 Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description A number of rectangular posters, photographs and other pictures of the same shape are pasted on a w…
看这篇博客前可以看一下扫描线求面积:线段树扫描线(一.Atlantis HDU - 1542(覆盖面积) 二.覆盖的面积 HDU - 1255(重叠两次的面积))  解法一·:两次扫描线 如图我们可以先用扫描线找出来横线的周长和,再用扫描线找纵线周长和 这里以横线来举例: 横线的长度 = [现在这次总区间被覆盖的程度和上一次总区间被覆盖的长度之差的绝对值] 下面有一点要注意的(参考链接:https://www.cnblogs.com/violet-acmer/p/11461660.html) 需…
1206 Picture  题目来源: IOI 1998 基准时间限制:2 秒 空间限制:131072 KB 分值: 160 难度:6级算法题  收藏  关注 给出平面上的N个矩形(矩形的边平行于X轴和Y轴),求这些矩形组成的所有多边形的周长之和.     例如:N = 7.(矩形会有重叠的地方).   合并后的多边形:     多边形的周长包括里面未覆盖部分方块的周长. Input 第1行:1个数N.(2 <= N <= 50000) 第2 - N + 1行,每行4个数,中间用空格分隔,分别…
复现过程 首先,我创建了一个基于Picture Library的图片文档库,名字是 Pic Lib 创建完毕后,我点击它的Upload 下拉菜单,点击Upload Picture按钮 在弹出的对话框中点击 Upload Multiple Files按钮 结果返回了下面的错误页面 如果查看浏览器左下角还会发现JavaScript错误信息,全文如下: User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Tride…
CStatic *pPic = (CStatic*)GetDlgItem(IDC_PICTURE); CBitmap bitmap; bitmap.LoadBitmapW(IDB_BITMAP2); pPic->SetBitmap((HBITMAP)bitmap.GetSafeHandle());//在Picture的Type调为Bitmap 像素修改: CStatic *pPic = (CStatic*)GetDlgItem(IDC_PICTURE); CBitmap bitmap; bitm…
POJ最近做过的原题. /* ID: cuizhe LANG: C++ TASK: picture */ #include <cstdio> #include <cstring> #include <string> #include <cmath> #include <algorithm> using namespace std; #define maxn 10000 #define lson l , m, rt<<1 #define…
This blog will be talking about the color image converted to black and white picture. The project structure as follow: The run result: ========================================================== source code: ===========================================…
Picture Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4475    Accepted Submission(s): 2207 Problem Description A number of rectangular posters, photographs and other pictures of the same shap…
Imagine a circle that contains all of human knowledge: By the time you finish elementary school, you know a little: By the time you finish high school, you know a bit more: With a bachelor's degree, you gain a specialty: A master's degree deepens tha…
If you’ve ever struggled building responsive websites, this post is for you. It’s part of a series on responsive design, in particular responsive images, pulled from my book, Responsive Web Design. If you find this excerpt useful, and want even more…
Eddy's picture Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6821    Accepted Submission(s): 3444 Problem Description Eddy begins to like painting pictures recently ,he is sure of himself to b…
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.LineNumberReader; import j…
又知道了线段树的一种用法,除了单点更新,区间更新,还有这种在一段线段上标号但不往下推. 真是神奇 hdu1828 #include <iostream> #include <stdio.h> #include <string.h> #include <math.h> #include <algorithm> #include <string> #include <queue> #include <map> #i…