#include <iostream.h>
#include <math.h>
typedef int RLE[2];
int w,n,ct,t;
RLE r[2000];
RLE cur,pos;
bool Move(RLE a, RLE b, int offset) {
if ( a[0]<0 || a[0]>=n ) return false;
b[0] = a[0]; b[1] = a[1]+offset;
while ( b[1]>=r[b[0]][1] && b[0]<n ) {
b[1] -= r[b[0]][1];
b[0]++;
}
if ( b[0]>=n ) return false;
while ( b[1]<0 && b[0]>=0 ) {
b[0]--;
b[1] += r[b[0]][1];
}
if ( b[0]<0 ) return false;
return true;
}
void Advance() {
int temp = r[pos[0]][1]-pos[1]-w-1;
if ( pos[1]>w && temp>0 ) {
cur[1] += temp;
ct += temp;
pos[1] += temp;
}
temp = w-2 - ct%w;
int temp2 = r[pos[0]][1]-pos[1]-2;
if ( pos[1]==0 || pos[1]==1 || ct%w==0 ) temp2 = 0;
int temp3,temp4;
RLE trle;
if ( !Move(pos, trle, -w-2) ) temp3 = w;
else temp3 = r[trle[0]][1]-trle[1]-3;
if ( !Move(pos, trle, w-2) ) temp4 = w;
else temp4 = r[trle[0]][1]-trle[1]-3;
temp = (temp<temp2)?temp:temp2;
temp = (temp<temp3)?temp:temp3;
temp = (temp<temp4)?temp:temp4;
if ( temp>0 ) {
cur[1] += temp;
ct += temp;
pos[1] += temp;
}
int hehe=0;
Move(pos, trle, -w-1);
if ( ct>=w && ct%w>0 ) {
temp = abs(r[trle[0]][0] - r[pos[0]][0]);
if ( temp>hehe ) hehe = temp;
}
Move(pos, trle, -w);
if ( ct>=w ) {
temp = abs(r[trle[0]][0] - r[pos[0]][0]);
if ( temp>hehe ) hehe = temp;
}
Move(pos, trle, -w+1);
if ( ct>=w && ct%w!=w-1 ) {
temp = abs(r[trle[0]][0] - r[pos[0]][0]);
if ( temp>hehe ) hehe = temp;
}
Move(pos, trle, -1);
if ( ct%w>0 ) {
temp = abs(r[trle[0]][0] - r[pos[0]][0]);
if ( temp>hehe ) hehe = temp;
}
Move(pos, trle, 1);
if ( ct%w!=w-1 ) {
temp = abs(r[trle[0]][0] - r[pos[0]][0]);
if ( temp>hehe ) hehe = temp;
}
Move(pos, trle, w-1);
if ( ct<t-w && ct%w>0 ) {
temp = abs(r[trle[0]][0] - r[pos[0]][0]);
if ( temp>hehe ) hehe = temp;
}
Move(pos, trle, w);
if ( ct<t-w ) {
temp = abs(r[trle[0]][0] - r[pos[0]][0]);
if ( temp>hehe ) hehe = temp;
}
Move(pos, trle, w+1);
if ( ct<t-w && ct%w!=w-1 ) {
temp = abs(r[trle[0]][0] - r[pos[0]][0]);
if ( temp>hehe ) hehe = temp;
}
if ( cur[0] == -1 ) {
cur[0] = hehe;
cur[1] = 1;
} else if ( hehe == cur[0] ) cur[1]++;
else {
cout<<cur[0]<<' '<<cur[1]<<endl;
cur[0] = hehe;
cur[1] = 1;
}
pos[1]++; ct++;
if ( pos[1] == r[pos[0]][1] ) {pos[0]++; pos[1]=0;}
}
void Output() {
cur[0] = -1; cur[1] = -1;
pos[0] = 0; pos[1] = 0;
while ( true ) {
if ( pos[0] == n ) break;
Advance();
}
cout<<cur[0]<<' '<<cur[1]<<endl;
}
int main()
{
cin>>w;
while ( w>0 ) {
cout<<w<<endl;
n=0;
cin>>r[n][0]>>r[n][1];
t=r[n][1];ct=0;
while ( r[n][1]>0 ) {
n++;
cin>>r[n][0]>>r[n][1];
t += r[n][1];
}
Output();
cout<<"0 0"<<endl;
cin>>w;
}
cout<<w<<endl;
return 0;
}
分享到:
相关推荐
poj1009 Edge Detection 可以直接AC的
【压缩包子文件的文件名称列表】:"POJ1009-Edge Detection.cpp"、"POJ1009-Edge Detection.doc" "POJ1009-Edge Detection.cpp"是解决该问题的C++源代码文件,很可能包含了实现边缘检测算法的函数和主程序逻辑。...
论文+代码 论文详细P. Perona and J. Malik. Scale-space and edge detection using anisotropic diffusion.IEEE Trans. 1990.
《一种计算方法的边缘检测》(A Computational Approach to Edge Detection)这篇经典论文由John Canny于1986年发表于IEEE Transactions on Pattern Analysis and Machine Intelligence期刊。该论文提出了一个全面且...
edge detection opencv
论文 Abstract In this paper, a novel edge detection method that computes image gradient using the concept of ...Keywords: edge detection, center of mass, integral image, multi-scale, fast computing.
C++ Qt implementation of edge detection algorithms. Currently available algorithms: Canny edge detector Sobel edge detector Prewitt edge detector Roberts cross Scharr operator The project includes ...
On candidates selection for hysteresis thresholds in edge detection
本项目"matlab开发-edgedetection"专注于实现这一功能,特别是针对硬件接口和物联网应用。 "EdgeDetection.m"是MATLAB代码文件,它很可能包含了具体的边缘检测算法实现。MATLAB提供了多种内置的边缘检测函数,如...
"Edge Detection Filters"这个压缩包很可能包含了各种边缘检测滤波器的介绍和实现。 边缘检测的基本原理是寻找像素强度的显著变化,这些变化通常表示图像的边界。常见的边缘检测算法有Canny算子、Sobel算子、...
Edge Detection边缘检测roberts,sobel,prewitt,laplacian
Contains three problems - Texture Classification using k means and Laws filters, Vehicle Classification using SIFT and SURF features and BOWs approach and Edge Detection techniques
We develop a new edge detection algorithm, holistically-nested edge detection (HED), which performs image-to-image prediction by means of a deep learning model that leverages fully convolutional ...
【ACO.zip_ACO_ACO edge_ACO edge detection_Edge detection ACO_edge】 蚁群算法(Ant Colony Optimization, ACO)是一种启发式优化算法,灵感来源于蚂蚁在寻找食物过程中通过释放信息素形成路径选择的行为。在...
本项目“matlab开发-EdgeDetection”聚焦于利用MATLAB内置的函数来实现这一过程。下面将详细阐述MATLAB中边缘检测的相关知识点。 1. **边缘检测原理**: 边缘检测是一种寻找图像亮度快速变化位置的技术,这些位置...
经典的canny算子,用于提取图像边缘,边缘保持滤波预处理的Canny算子较原有Canny算子在边缘检测性能方面有一定的改善;边缘保持滤在Canny算子实施边缘检测前,运用具有边缘保持性能的滤波器做预处理....
在1986年,John Canny发表了一篇题为《A Computational Approach to Edge Detection》的论文,该论文对边缘检测技术的发展产生了深远影响。边缘检测是图像处理领域中的一项基本技术,它主要用于从图像中识别出边缘,...
本压缩包文件"edge detection.rar"包含了一系列与边缘检测相关的资源,尤其是应用Canny、Sobel和Roberts算子来识别癌症细胞边缘的方法。下面将详细阐述这些边缘检测技术及其在癌症细胞检测中的应用。 首先,Canny...