Page 2 of 2

problem solved...

Posted: Thu Feb 21, 2008 8:42 am
by guang_1225
This testcase:

Code: Select all

1

1                      9
1
2
3
4
5
6
7
8
9
10
The output should be:

Code: Select all

Size 1
              9
1
2
3
4
5
6
7
8
9
10


598: Bundling eccentric newspapers

Posted: Sat Feb 23, 2008 8:30 pm
by Schneider
CUHK made 598 an assignment problem and implemented their own online judge, which accepts some programmes UVa rejects and rejects some UVa accepts. Moreover, my friend Mr. Guang discovered that UVa takes the lines containing "*" or 1-2 numbers to be exactly 9 characters long (10 if passed through fgets) and anything after that, with or without a line-feed occurring, is considered the first newspaper title. He illustrated his finding in reply to his own post. Confirmation or evidence to the contrary is appreciated.

My code got accepted at last without compromising to the 9-char limit. Another issue: the online judge reported WA previously but all I did was printing one extra linefeed at the end.

Posted: Tue Feb 26, 2008 11:23 am
by windkit
Accepted in UVa
but

Limit Exceeded: Output Limit Exceeded

in CU judge= =

Re: 598: Bundling eccentric newspapers

Posted: Sat Jan 29, 2011 12:53 pm
by Imti
Thnx Jackie for his necessary post...
[cpp] scanf("%d", &n);
gets(tmp), gets(tmp);
for (NULL; n--; NULL)
{
gets(tmp);
c = sscanf(tmp, "%d%d", &a, &b);
t = 0;
for (NULL; gets(buf[t]) && buf[t][0]; ++t)
;
if (c == 0)
display(1, t);
else if (c == 1)
display(a, a);
else
display(a, b);
if (n)
printf("\n");
}[/cpp]
I was getting WA.Because I was doing

Code: Select all

scanf("%d",&n);
gets(tmp);
while(n--)
{
gets(tmp);
gets(tmp);
i=0;
while(gets(buf[i])&&buf[i])
   i++;
if(str[0]=='*')
{s=1;e=i;}
else if(str[1]=='\0')
{s=atol(tmp);e=s;}
else
{ssacnf(tmp,"%d%d",&s,&e);}
if(flag)
 printf("\n");
flag=1;
for(size=s;size<=e;size++)
{
display_output();
printf("\n");
}
}
But this code was giving me WA.When I transformed input parsing system to like jackie's code,i got acc.Plz can anyone make me understand how differs my approach from jackie's one?

Re: 598: Bundling eccentric newspapers

Posted: Fri Dec 16, 2011 9:38 am
by ashleyjames222
you are not using this tag (NULL; n--; NULL)

Re: 598: Bundling eccentric newspapers

Posted: Sat Jun 23, 2012 10:44 pm
by magurmach
Getting WA in this problem. No idea why!
Code link:
Code removed after AC
Made silly mistakes
a b means show all subset sizes from a to b, inclusive
Tested nearly all cases available. Plz help.
Thanks in advance!

Re: 598: Bundling eccentric newspapers

Posted: Fri Oct 12, 2012 9:58 pm
by AhmadKhatar
Hi!
I don't know why I get WA.
Does anybody know the bug?
Thanks in advance! :D
Here is my code:

Code: Select all

#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>

using namespace std;

int m;
string names [ 12 ];
int cnt;
char query [ 63 ];

void process();
void backtrack( int stInd, int rem, string output );

int main()
{
	char tLine [ 63 ];

	cin >> m;
	cin.ignore();
	cin.ignore();

	for ( int i = 0; i < m; i++ )
	{
		cnt = 0; // refresh

		cin.getline( query, 63, '\n' );

		cin.getline( tLine, 63, '\n' );
		while ( tLine[ 0 ] != NULL )
		{
			names[ cnt++ ] = tLine;
			cin.getline( tLine, 63, '\n' );
		}

		if ( i >= 1 )
		{
			cout << endl;
		}
		process();
	}

	return 0;
}

void process()
{
	int st, end;

	if ( query[ 0 ] == '*' )
	{
		st = 1;
		end = cnt;
	}
	else
	{
		char * tokenPtr;
		tokenPtr = strtok( query, " " );
		st = atoi( tokenPtr );
		tokenPtr = strtok( NULL, " " );
		if ( tokenPtr == NULL )
		{
			end = st;
		}
		else
		{
			end = atoi( tokenPtr );
		}
	}

	for ( int i = st; i <= end; i++ )
	{
		if ( i >= st + 1 )
		{
			cout << endl;
		}
		cout << "Size " << i << endl;
		backtrack( 0, i, "" );
	}
}

void backtrack( int stInd, int rem, string output )
{
	string tOut;
	for ( int i = stInd; i < cnt - (rem - 1); i++ )
	{
		tOut = output;
		tOut += names[ i ];
		if ( rem >= 2 )
		{
			tOut += ", ";
			backtrack( i + 1, rem - 1, tOut );
		}
		else
		{
			cout << tOut << endl;
		}
	}
}

Re: 598: Bundling eccentric newspapers

Posted: Fri Oct 12, 2012 11:35 pm
by brianfry713
For this input posted by Jan:

Code: Select all

3

2 3
Times
Herald-Tribune
Post
New Advocate

*
abc
def

1
pqm
The AC output is:

Code: Select all

Size 2
Times, Herald-Tribune
Times, Post
Times, New Advocate
Herald-Tribune, Post
Herald-Tribune, New Advocate
Post, New Advocate

Size 3
Times, Herald-Tribune, Post
Times, Herald-Tribune, New Advocate
Times, Post, New Advocate
Herald-Tribune, Post, New Advocate


Size 1
abc
def

Size 2
abc, def


Size 1
pqm


Re: 598: Bundling eccentric newspapers

Posted: Sat Oct 13, 2012 12:03 am
by AhmadKhatar
So the sample output was wrong!
Many thanks!! :D

Re: 598: Bundling eccentric newspapers

Posted: Tue Dec 04, 2012 10:45 am
by afruizc
I don't know what wrong with My code. I've reviewed it several times. It's passed all the test cases so far. I'm getting WA if anyone can help me I would really appreciate.

Code: Select all

Acc....
Removed after realizing a wasn't doing what was asked int the problem description

Re: 598 - Bundling Newspapers

Posted: Fri Oct 10, 2014 5:29 pm
by Zyaad Jaunnoo
Be careful with the output ( I got caught :-? ):
  • [1] Print a blank line AFTER each subset size group
    [2] Print a blank line BETWEEN datasets