| Time Limit: 2000MS | Memory Limit: 65536K | |
| Total Submissions: 2194 | Accepted: 869 |
Description
In this problem, you are given a sequence S1, S2, ...,Sn of squares of different sizes. The sides of the squares are integer numbers. We locate the squares on the positivex-y quarter of the plane, such that their sides make 45 degrees withx and y axes, and one of their vertices are on y=0 line. Letbi be the x coordinates of the bottom vertex of Si. First, put S1 such that its left vertex lies onx=0. Then, put S1, (i > 1) at minimum bi such that
- bi > bi-1 and
- the interior of Si does not have intersection with the interior ofS1...Si-1.
The goal is to find which squares are visible, either entirely or partially, when viewed from above. In the example above, the squaresS1, S2, and S4 have this property. More formally,Si is visible from above if it contains a point p, such that no square other thanSi intersect the vertical half-line drawn from p upwards.
Input
The input consists of multiple test cases. The first line of each test case isn (1 ≤ n ≤ 50), the number of squares. The second line containsn integers between 1 to 30, where the ith number is the length of the sides ofSi. The input is terminated by a line containing a zero number.
Output
For each test case, output a single line containing the index of the visible squares in the input sequence, in ascending order, separated by blank characters.
Sample Input
4 3 5 1 4 3 2 1 2 0
Sample Output
1 2 4 1 3
Source
#include<stdio.h>
struct point{
int l,r,len;
}p[58];
int MAX(int a,int b)
{
return a>b?a:b;
}
int myabs(int x)
{
return x<0?-x:x;
}
int main()
{
int n,i,j,flag;
while(scanf("%d",&n)&&n)
{
for(i=0;i<n;i++)
{
scanf("%d",&p[i].len);
p[i].l=0;
for(j=0;j<i;j++)
p[i].l=MAX(p[i].l,p[j].r-myabs(p[j].len-p[i].len));
p[i].r=p[i].l+2*p[i].len;
}
for(i=0;i<n;i++)
{
for(j=0;j<i;j++)
if(p[i].l<p[j].r)
{
if(p[i].len>p[j].len) p[j].r=p[i].l;
else p[i].l=p[j].r;
}
}
for(flag=i=0;i<n;i++)
{
if(p[i].l<p[i].r)
{
if(flag) printf(" ");
printf("%d",i+1);
flag=1;
}
}
printf("\n");
}
return 0;
}
本文概述了AI音视频处理领域的关键技术,包括视频分割、语义识别、自动驾驶、AR、SLAM等,并探讨了其在实际应用中的作用。
&spm=1001.2101.3001.5002&articleId=11834905&d=1&t=3&u=c501d50e38554874ab84d383521ec2cd)
1553

被折叠的 条评论
为什么被折叠?



