Page 1 of 1
Posted: Thu Oct 20, 2005 12:04 am
by Raj Ariyan
Hi,
Here is the link abt explanation of 10928. Let me know, If u face problem again after see this page. Good Luck.
http://online-judge.uva.es/board/viewtopic.php?t=9112
Posted: Thu Oct 20, 2005 12:44 pm
by misof
Sorting isn't necessary, but the output has to be sorted. The most tricky part of this problem is reading the input data correctly. For each test case:
- get a line with P
- get P lines with the descriptions of neighborhoods
- find the index of the line that contains the least amount of numbers (if there are more possible answers, store all of them and output them in increasing order)
- output it
- if this is not the last test case, get a line (the empty line that separates test cases)
Check whether you don't have unnecessary whitespaces in your output.
Try the following test data:
Code: Select all
2
2
1
2
13
10 11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
1 2 3 4
1 2 3 4
1 2 3 4
The correct output:
There are no spaces after 2 and 10, there is an end-of-line character after both of them.
Posted: Tue May 23, 2006 4:34 pm
by Moha
You don't need to count the numbers in each line, just count the space!
488 WA,PLES HELP
Posted: Wed Dec 19, 2007 2:25 pm
by turcse143
here is sample input output: I got WA PLES help? Is there any special case?
input:
4
3
2
1 3
2 1
4
2
3
1 4 2
2 1 3
2
1
2
13
10 11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
1 2 3 4
1 2 3 4
1 2 3 4
output:
1
1 2
1 2
2 3 4 5 6 7 8 9 10
Press any key to continue
Posted: Thu Dec 20, 2007 6:34 pm
by turcse143
thanks changing the input technique i got accept
Re: 10928 - My Dear Neighbours
Posted: Tue Sep 16, 2008 9:24 pm
by sharath
My code below is passing all the test cases mentioned in the thread but getting WA when submitted..
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int a[1000];
int main()
{
int n,p,d,i,min;
char str[1000];
cin>>n;
while (n-- != 0)
{
i = 0;
cin>>p;
min = p-1;
memset(a,0,sizeof(a));
while (p != 0)
{
fgets(str,999,stdin);
istringstream str1(str);
while (str1 >> d)
{
a++;
}
if (a != 0)
{
if (a < min)
{
min = a;
}
i++;
p--;
}
}
for (i=0;i<1000;i++)
{
if (a == min)
{
cout<<i+1<<" ";
}
}
cout<<endl;
}
return 0;
}
What is the mistake??
Re: 10928 - My Dear Neighbours
Posted: Mon Dec 22, 2008 12:41 pm
by mukit
I'm getting WA in this problem
Please give some I/O.
Thank's in advance.
Re: 10928 - My Dear Neighbours
Posted: Mon Dec 22, 2008 1:07 pm
by mukit
Ok forget that. Got AC. But one thing...
for misof's input
Code: Select all
2
2
1
2
13
10 11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
1 2 3 4
1 2 3 4
1 2 3 4
output will be,
So just a newline '\n' (not a blank line) after every case including the last one.
Re: 10928 - My Dear Neighbours
Posted: Sat Sep 11, 2010 9:09 pm
by Shafaet_du
Too easy a problem. Dont need to make the thinks complex,just count inputs in every line,index them and find out the lowes value. then print the ouputs.
Only one space will separate the outputs,which makes the problem even more easier.
if you still get wa,check this IO:
Code: Select all
2
8
2
4 3
1 2 3
2 1 3 4
1 2 3 4 5
5 3 1 3 5
2
5
12
11 10 9
1 2 3
1 2 3 4
5 6 7 8
4 3 1 2
11 9 3
1 2 3 4 5 6 7 8 9
1 2 10 9 8 7
1 2 3 4
6 7 8
5 4 3
1 2 3 4 5
Output from my ac code:
Re: 10928 - My Dear Neighbours
Posted: Fri Mar 18, 2011 3:34 am
by DD
sharath wrote:My code below is passing all the test cases mentioned in the thread but getting WA when submitted..
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int a[1000];
int main()
{
int n,p,d,i,min;
char str[1000];
cin>>n;
while (n-- != 0)
{
i = 0;
cin>>p;
min = p-1;
memset(a,0,sizeof(a));
while (p != 0)
{
fgets(str,999,stdin);
istringstream str1(str);
while (str1 >> d)
{
a++;
}
if (a != 0)
{
if (a < min)
{
min = a;
}
i++;
p--;
}
}
for (i=0;i<1000;i++)
{
if (a == min)
{
cout<<i+1<<" ";
}
}
cout<<endl;
}
return 0;
}
What is the mistake??
The size of str is not enough. The number of neighbors in this problem will not exceed 1000 but the length of each line may exceed. You should get A.C. once you enlarge the length of str. 
Posted: Fri Aug 12, 2011 6:55 am
by Farsan
misof wrote:Sorting isn't necessary, but the output has to be sorted. The most tricky part of this problem is reading the input data correctly. For each test case:
- get a line with P
- get P lines with the descriptions of neighborhoods
- find the index of the line that contains the least amount of numbers (if there are more possible answers, store all of them and output them in increasing order)
- output it
if this is not the last test case, get a line (the empty line that separates test cases)[/even for the last test case you have 2 print a new line all u have 2 worry about is whitespaces]
Check whether you don't have unnecessary whitespaces in your output.
Try the following test data:
Code: Select all
2
2
1
2
13
10 11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
11 12 13
1 2 3 4
1 2 3 4
1 2 3 4
The correct output:
There are no spaces after 2 and 10, there is an end-of-line character after both of them.
Re: 10928 - My Dear Neighbours
Posted: Sun Aug 17, 2014 10:34 am
by moxlotus
Runtime Error on my following code. Can someone tell me why?
AC'ed
Re: 10928 - My Dear Neighbours
Posted: Mon Aug 18, 2014 6:35 pm
by lighted
Increase array limit
It must be
You will get PE. Don't print extra space after last number.
Don't forget to remove your code after getting accepted.

Re: 10928 - My Dear Neighbours
Posted: Fri Mar 13, 2015 12:55 pm
by uDebug
Replying to follow the thread.