Page 1 of 2
10714 - Ants
Posted: Sat Aug 13, 2005 8:42 am
by S M Adnan
I solved this (but not got AC) problem like...
minimum time = max(mininum time to get out of the pol)
and
maximum time = max(maximum time to get out of the pol)
So, can anyone tell me what is wrong with me.
Posted: Sat Aug 13, 2005 3:39 pm
by Cho
I've seen someone who got WA because he forgot to initialize the min and max variable for each test case.
Re: 10714 Ants
Posted: Tue Aug 16, 2005 9:20 am
by Martin Macko
If still getting WAs, try to post your code here...
About 10714
Posted: Sun Sep 04, 2005 12:37 pm
by Rocky
It Is A Easy & Sort Problem.But If U Want I Can Sent Some I/O For You
...
Posted: Sat Jun 10, 2006 11:21 am
by Solmon K.
I think ur algo is not wrong..
wa on this problem
Posted: Fri Jul 07, 2006 3:25 pm
by marif
Pls help me. W.A. is boaring. I used simple searching algo...
minimum value
{
i=last item that is found (and matched) before the mid value.
j=first item that is found (and matched) after the mid value.
if(i>(total length-j))minimum=i;
else minimum=total length-j;
}
maximum value
{
i=the smallest item of the array.
j=the largest item of the array.
if((total length -i)>j)
maximum=total length-i;
else maximum=j;
}
what is the wrong with it. I have used few inputs on this board and it was ok. Pls help.

714: Ants --- Some critical I/O please
Posted: Sun Jul 09, 2006 9:04 pm
by rahurprem
I'm getting WA in this problem. I'm sending my findMin() & findMax() code blocks. I hope until now that those two blocks are producing correct results. So help me in this matter.
Code: Select all
int findMin()
{
int i;
int min = L;
int mid = L/2; /*This is the mid of pole*/
/**mid theke shobcheye kaser ant khojo**/
/**Let's find which ant is closest to the mid position****/
/*STEP 1: Search Left side upto mid**/
for(i=0; a[i]<mid; i++)
{
if(min> abs(a[i]-mid))
min = abs(a[i]-mid);
}
/*STEP 2: Search from Right side upto mid**/
for(i=N-1; a[i]>=mid; i--)
{
if(min>abs(a[i]-mid))
min = abs(a[i]-mid);
}
return mid-min; /*This is the minimum distance, isn't it?*/
}
Code: Select all
int findMax()
{
int i,j;
int max=-1;
/***
i=the smallest item of the array.
j=the largest item of the array.
if((total length -i)>j)
maximum=total length-i;
***/
i = a[0];
j = a[N-1];
if((L-i)>j)
max= L-i;
else
max= j;
return max;
}
It'll be a great help if you provide me some i/o to prove this algo wrong.
Wishes,
R.P.
10714 - Ants W.A
Posted: Tue Jul 11, 2006 2:26 pm
by unaben
I got W.A on this problem.

Could someone plz give me the I/O.
Here is my code:
REMOVED AFTER AC!
Re: 10714 - Ants W.A
Posted: Sun Jul 23, 2006 10:12 pm
by Martin Macko
unaben wrote:I got W.A on this problem.

Could someone plz give me the I/O.
What if
hold==
distance?
your code wrote:.......if(hold<distance and hold>min)
.......{
...........min = hold;
.......}....
.......else if(hold>distance and distance>min)
.......{
...........min = distance;
.......}...
Re: 714: Ants --- Some critical I/O please
Posted: Sun Jul 23, 2006 10:21 pm
by Martin Macko
rahurprem wrote:I'm getting WA in this problem. I'm sending my findMin() & findMax() code blocks. I hope until now that those two blocks are producing correct results. So help me in this matter.
I think your
findMin() doesn't work for odd
Ls. Think about something like that:
Re: 10714 - Ants W.A
Posted: Sun Jul 23, 2006 10:22 pm
by Martin Macko
and btw, if there is a thread on a particular problem, please, use that thread and do not create a new one.
Posted: Mon Jul 24, 2006 11:02 am
by unaben
Thanx Macko

What a stupid mistake. I got AC now

Posted: Mon Jul 24, 2006 1:49 pm
by Martin Macko
unaben wrote:Thanx Macko

What a stupid mistake. I got AC now

After you got AC, please, remove the code from your first post, so there won't be too many spoilers here

Why WA??
Posted: Sat Mar 03, 2007 5:43 pm
by ranban282
I have absolutely no idea why I'm getting WA.
Here's the code:
Code: Select all
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<list>
#include<queue>
#include<cctype>
#include<stack>
#include<map>
#include<set>
using namespace std;
int main()
{
int cases;
cin>>cases;
while(cases--)
{
int l,n;
scanf(" %d %d",&l,&n);
vector<int> v(n);
for(int i=0;i<n;i++)
{
scanf(" %d",&v[i]);
}
sort(v.begin(),v.end());
int ma=max(l-v[0],v.back());
int mi=ma;
for(int i=0;i<n-1;i++)
{
mi=min(mi,max(v[i],l-v[i+1]));
}
if(n==1)
mi=min(v[0],l-v[0]);
printf("%d %d\n",mi,ma);
}
return 0;
}
Could anyone provide me with I/0?
Posted: Sat May 19, 2007 8:39 pm
by Grazyna
Can someone explain why the output for
is
and not
Thanks in advance for any reply.