## 10947 - Bear with me, again..

All about problems in Volume 109. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Tamagodzi
New poster
Posts: 22
Joined: Thu Apr 28, 2005 10:56 pm
Thnx mjf ...

0.150 seconds after that without using optimized io

Official solution uses a non-logical algorithm, that says that you can't go from one island to another if they overlap. We're going to change the input, so that no 2 islands intersect.

And a negative island number is logical? ...

0.123 after switching to scanf/printf from cin cout ^^
Last edited by Tamagodzi on Sat Oct 22, 2005 4:31 pm, edited 1 time in total.

little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm
Adrian will probably say something like: SCH3155 D0NN3RW3773R v#RD4MM73 SCHW31N3R31!

Guru
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany
little joey wrote:Adrian will probably say something like: SCH3155 D0NN3RW3773R v#RD4MM73 SCHW31N3R31!
Yes, something like that
Well, I had two "real" WA on that problem anyway, since first I had a bug in my formula.

DongJoo Kim
New poster
Posts: 20
Joined: Tue Sep 20, 2005 9:20 am
Location: Daejeon, Korea
Somthing funny about this problem is that I actually got ACC before rejudge although I didn't submit the code with wrong formula.

In my code, the distance formula was wrong

it was...

dist = (x1-y1)*(x1-y1) + (x2-y2)*(x2-y2) ;

I have no idea Y I got AC... at that time.

It was very amazing

Per
A great helper
Posts: 429
Joined: Fri Nov 29, 2002 11:27 pm
Location: Sweden
little joey wrote:This problem definitly needs re-rejudging (and I want my perfect score 6 AC for 6 submissions for the contest back...).
It seems the problem is rejudged now, there are a lot more people with 6 solved, you being one of them. Still lots of TLEs though, so I guess they still have a lot more I/O than during the actual contest. Oh well.

For some reason they seem to have rejudged F as well, my solution where I accidentally typed "int isprime[10000010];" rather than "int isprime[1000010];" and (rightfully) got MLE has been rejudged to AC. Strange.

sclo
Guru
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm
Location: Vancouver, BC, Canada
Contact:
I found that after the rejudge, my O(n^3) solution is TLE, but O(n^2) is AC.

arjun2304
New poster
Posts: 1
Joined: Sat May 05, 2012 4:34 pm

### 10947 - Bear with me, again..

Code: Select all

``````#include<iostream>
#include<cstdio>
#include<cmath>
#include<climits>

using namespace std;

int xc[110],yc[110],r[110];
double a[110][110];

double min(double x,double y)
{
if(x>y)return y;
return x;
}
double max(double x,double y)
{
if(x>y)return x;
return y;
}
double distance(int x1,int y1,int x2,int y2)
{
return sqrt(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)));
}
int main()
{
int i,j,n,sx,sy,sr,dx,dy,dr;
double k,m;
while(scanf("%lf%lf",&k,&m)==2)
{
cin>>xc[0]>>yc[0]>>r[0]>>dx>>dy>>dr;
cin>>n;
for(i=1;i<=n;i++)
scanf("%d%d%d",&xc[i],&yc[i],&r[i]);
xc[n+1]=dx;yc[n+1]=dy;r[n+1]=dr;
for(i=0;i<=n+1;i++)
{
for(j=0;j<=n+1;j++)
{
a[i][j]=INT_MAX;
}
a[i][i]=0;
}
for(i=0;i<=n+1;i++)
{
for(j=i+1;j<=n+1;j++)
{
a[i][j]=a[j][i]=distance(xc[i],yc[i],xc[j],yc[j])-r[i]-r[j];
}
}
for(k=0;k<=n+1;k++)
{
for(i=0;i<=n+1;i++)
{
for(j=0;j<=n+1;j++)
{
a[i][j]=min(a[i][j],max(a[i][k],a[k][j]));
}
}
}
if(a[0][n+1]>(k*m)||a[0][n+1]==INT_MAX)
printf("Larry and Ryan will be eaten to death.\n");
else
printf("Larry and Ryan will escape!\n");
}
return 0;
}

``````

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 10947 : wy WA.????

Compile Error:

Code: Select all

``````code.cpp: In function 'int main()':
code.cpp:57:31: error: invalid types 'double [110][double]' for array subscript
code.cpp:57:36: error: invalid types 'double [110][110][double]' for array subscript``````
Check input and AC output for thousands of problems on uDebug!

DD
Experienced poster
Posts: 145
Joined: Thu Aug 14, 2003 8:42 am
Location: Mountain View, California
Contact:

### Re: 10947 : wy WA.????

This problem is easy enough so you should not get W.A.
Have you ever...
• Wanted to work at best companies?
• Struggled with interview problems that could be solved in 15 minutes?
• Wished you could study real-world problems?
If so, you need to read Elements of Programming Interviews.