10714  Ants
Moderator: Board moderators

 New poster
 Posts: 4
 Joined: Wed Aug 10, 2005 10:43 pm
 Location: Dhaka, Bangladesh
 Contact:
10714  Ants
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.
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.
Hul Hul
 Martin Macko
 A great helper
 Posts: 481
 Joined: Sun Jun 19, 2005 1:18 am
 Location: European Union (Slovak Republic)
Re: 10714 Ants
If still getting WAs, try to post your code here...
About 10714
It Is A Easy & Sort Problem.But If U Want I Can Sent Some I/O For You
wa on this problem
Pls help me. W.A. is boaring. I used simple searching algo...
what is the wrong with it. I have used few inputs on this board and it was ok. Pls help.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 lengthj))minimum=i;
else minimum=total lengthj;
}
maximum value
{
i=the smallest item of the array.
j=the largest item of the array.
if((total length i)>j)
maximum=total lengthi;
else maximum=j;
}

 New poster
 Posts: 10
 Joined: Mon Mar 28, 2005 5:59 pm
 Location: Dhaka, Bangladesh
 Contact:
714: Ants  Some critical I/O please
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.
It'll be a great help if you provide me some i/o to prove this algo wrong.
Wishes,
R.P.
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=N1; a[i]>=mid; i)
{
if(min>abs(a[i]mid))
min = abs(a[i]mid);
}
return midmin; /*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 lengthi;
***/
i = a[0];
j = a[N1];
if((Li)>j)
max= Li;
else
max= j;
return max;
}
Wishes,
R.P.
Programmer? No, no, i am a speedy typist.
10714  Ants W.A
I got W.A on this problem. Could someone plz give me the I/O.
Here is my code:
REMOVED AFTER AC!
Here is my code:
REMOVED AFTER AC!
Last edited by unaben on Tue Jul 25, 2006 11:29 pm, edited 1 time in total.
 Martin Macko
 A great helper
 Posts: 481
 Joined: Sun Jun 19, 2005 1:18 am
 Location: European Union (Slovak Republic)
Re: 10714  Ants W.A
What if hold==distance?unaben wrote:I got W.A on this problem. Could someone plz give me the I/O.
your code wrote:.......if(hold<distance and hold>min)
.......{
...........min = hold;
.......}....
.......else if(hold>distance and distance>min)
.......{
...........min = distance;
.......}...
 Martin Macko
 A great helper
 Posts: 481
 Joined: Sun Jun 19, 2005 1:18 am
 Location: European Union (Slovak Republic)
Re: 714: Ants  Some critical I/O please
I think your findMin() doesn't work for odd Ls. Think about something like that: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.
Code: Select all
1
3 1
3
 Martin Macko
 A great helper
 Posts: 481
 Joined: Sun Jun 19, 2005 1:18 am
 Location: European Union (Slovak Republic)
Re: 10714  Ants W.A
and btw, if there is a thread on a particular problem, please, use that thread and do not create a new one.
 Martin Macko
 A great helper
 Posts: 481
 Joined: Sun Jun 19, 2005 1:18 am
 Location: European Union (Slovak Republic)
Why WA??
I have absolutely no idea why I'm getting WA.
Here's the code:
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(lv[0],v.back());
int mi=ma;
for(int i=0;i<n1;i++)
{
mi=min(mi,max(v[i],lv[i+1]));
}
if(n==1)
mi=min(v[0],lv[0]);
printf("%d %d\n",mi,ma);
}
return 0;
}
Could anyone provide me with I/0?
Can someone explain why the output for
is
and not
Thanks in advance for any reply.
Code: Select all
1
10 3
3 7 9
Code: Select all
3 9
Code: Select all
3 8
Thanks in advance for any reply.