105 - The Skyline Problem
Moderator: Board moderators
105
I try to do the problem 105, but received this:
Warning: Your program would get a Presentation Error in a true contest.
The 24-hours judge interpretes it as an "Accepted" problem.
what does it mean?
[cpp]
#include <fstream>
#include <iostream>
using namespace std;
#ifndef ONLINE_JUDGE
ifstream FIN("skyline.in");
#else
istream& FIN = cin;
#endif
ostream& FOUT = cout;
void main()
{
int H[10002] = {0};
while(FIN && !FIN.eof())
{
int l,h,r;
FIN>>l>>h>>r;
for(int i=l;i<r;i++)
{
if(H<h)
H = h;
}
}
for(int i=1;i<10002;i++)
{
if(H!=H[i-1])
FOUT<<i<<' '<<H<<' ';
}
}
[/cpp]
Warning: Your program would get a Presentation Error in a true contest.
The 24-hours judge interpretes it as an "Accepted" problem.
what does it mean?
[cpp]
#include <fstream>
#include <iostream>
using namespace std;
#ifndef ONLINE_JUDGE
ifstream FIN("skyline.in");
#else
istream& FIN = cin;
#endif
ostream& FOUT = cout;
void main()
{
int H[10002] = {0};
while(FIN && !FIN.eof())
{
int l,h,r;
FIN>>l>>h>>r;
for(int i=l;i<r;i++)
{
if(H<h)
H = h;
}
}
for(int i=1;i<10002;i++)
{
if(H!=H[i-1])
FOUT<<i<<' '<<H<<' ';
}
}
[/cpp]
Hi~~
You received Accepted (P.E.). Right?
That means that your output matches with the sample output for the content, but differs with some minor things. e.g. space, the return at the end of the line, a blank line, etc.
That means that your output matches with the sample output for the content, but differs with some minor things. e.g. space, the return at the end of the line, a blank line, etc.
Oh, I found another minor printing error by having taken a look at your code.
Your output is printed by
[cpp]
for(int i=1;i<10002;i++)
{
if(H!=H[i-1])
FOUT<<i<<' '<<H<<' ';
}
[/cpp]
The above code will print the numbers with a space after each number. Right?
e.g. If the number to be outputted is 1 2 3 4 5 6, you will print
1_2_3_4_5_6_\n
where _ stands for a space character
and \n stands for a new line character
However, the standand output should be
1_2_3_4_5_6\n
So you got what I mean? (Haha... my poor English~~)
Your output is printed by
[cpp]
for(int i=1;i<10002;i++)
{
if(H!=H[i-1])
FOUT<<i<<' '<<H<<' ';
}
[/cpp]
The above code will print the numbers with a space after each number. Right?
e.g. If the number to be outputted is 1 2 3 4 5 6, you will print
1_2_3_4_5_6_\n
where _ stands for a space character
and \n stands for a new line character
However, the standand output should be
1_2_3_4_5_6\n
So you got what I mean? (Haha... my poor English~~)
-
- New poster
- Posts: 10
- Joined: Mon Jul 01, 2002 11:15 pm
- Location: Germany
105 Help with SIGSEGV Error
Can anyone help ?
I keep getting SIGSEGV errors when submitting and I can't figure out why ...
[cpp]
#include <stdio.h>
#include <string.h>
#include <malloc.h>
main()
{
/* redirect standard input + output if necessary */
#ifndef ONLINE_JUDGE
freopen( "data.in", "r", stdin );
freopen( "data.out", "w", stdout );
#endif
/* load input */
int iLeft, iTop, iRight;
int i;
int *iSkyline = (int*)malloc(5000*sizeof(int));
for( i=0; i<=5000; i++)
iSkyline=0;
while( scanf("%d %d %d", &iLeft, &iTop, &iRight) != EOF )
{
/* get height map */
for( int j=iLeft; j<iRight; j++ )
{
if( iSkyline[j] < iTop )
iSkyline[j] = iTop;
}
}
/* start output */
int iCurrentHeight = 0;
for( i=0; i<= 5000; i++ )
{
if( iCurrentHeight != iSkyline )
{
printf("%i %i ", i, iSkyline );
iCurrentHeight = iSkyline;
}
}
}
[/cpp]
I keep getting SIGSEGV errors when submitting and I can't figure out why ...
[cpp]
#include <stdio.h>
#include <string.h>
#include <malloc.h>
main()
{
/* redirect standard input + output if necessary */
#ifndef ONLINE_JUDGE
freopen( "data.in", "r", stdin );
freopen( "data.out", "w", stdout );
#endif
/* load input */
int iLeft, iTop, iRight;
int i;
int *iSkyline = (int*)malloc(5000*sizeof(int));
for( i=0; i<=5000; i++)
iSkyline=0;
while( scanf("%d %d %d", &iLeft, &iTop, &iRight) != EOF )
{
/* get height map */
for( int j=iLeft; j<iRight; j++ )
{
if( iSkyline[j] < iTop )
iSkyline[j] = iTop;
}
}
/* start output */
int iCurrentHeight = 0;
for( i=0; i<= 5000; i++ )
{
if( iCurrentHeight != iSkyline )
{
printf("%i %i ", i, iSkyline );
iCurrentHeight = iSkyline;
}
}
}
[/cpp]
-
- Experienced poster
- Posts: 167
- Joined: Fri Oct 19, 2001 2:00 am
- Location: Saint Petersburg, Russia
-
- New poster
- Posts: 10
- Joined: Mon Jul 01, 2002 11:15 pm
- Location: Germany
-
- Experienced poster
- Posts: 167
- Joined: Fri Oct 19, 2001 2:00 am
- Location: Saint Petersburg, Russia
-
- New poster
- Posts: 10
- Joined: Mon Jul 01, 2002 11:15 pm
- Location: Germany
Problem 105 - Presentation Error
Hi!
I'm wondering if anyone else got a presentation error after submitting. The program is accepted, but there's something wrong with the output and I can't figure what !? ( No extra spaces / CRs etc ... )
Sample Input:
I'm wondering if anyone else got a presentation error after submitting. The program is accepted, but there's something wrong with the output and I can't figure what !? ( No extra spaces / CRs etc ... )
Sample Input:
- 1 11 5
2 6 7
3 13 9
12 7 16
14 3 25
19 18 22
23 13 29
24 4 28
- 1 11 3 13 9 0 12 7 16 3 19 18 22 3 23 13 29 0
-
- New poster
- Posts: 10
- Joined: Mon Jul 01, 2002 11:15 pm
- Location: Germany
-
- New poster
- Posts: 10
- Joined: Mon Jul 01, 2002 11:15 pm
- Location: Germany
Nope, nothing.
My modified output version looks like that
[cpp]
int iCurrentHeight = 0;
int bFirst = true;
for( i=0; i< 10000; i++ )
{
if( iCurrentHeight != iSkyline )
{
if(bFirst)
{
printf("%i %i", i, iSkyline );
bFirst = false;
}
else
{
printf(" %i %i", i, iSkyline );
}
iCurrentHeight = iSkyline;
}
}
[/cpp]
My modified output version looks like that
[cpp]
int iCurrentHeight = 0;
int bFirst = true;
for( i=0; i< 10000; i++ )
{
if( iCurrentHeight != iSkyline )
{
if(bFirst)
{
printf("%i %i", i, iSkyline );
bFirst = false;
}
else
{
printf(" %i %i", i, iSkyline );
}
iCurrentHeight = iSkyline;
}
}
[/cpp]