Page 2 of 7

Posted: Sat Feb 12, 2005 12:43 pm
by Eduard
O.I find my mistake and got AC. :D :D

Posted: Sat Feb 12, 2005 6:47 pm
by GVahe
Did you realize that my test case was

Code: Select all

8
1
-1
1
-100
1
-1
1
?

Posted: Sat Feb 12, 2005 9:09 pm
by Eduard
GVahe wrote:Did you realize that my test case was

Code: Select all

8
1
-1
1
-100
1
-1
1
?
Of course not. If you want others to understand your test, you must write your tests in right form.Anyway my program were giving right answer.
Eduard

offtop

Posted: Mon Feb 14, 2005 7:18 pm
by GVahe
Eduard wrote:
GVahe wrote:Did you realize that my test case was

Code: Select all

8
1
-1
1
-100
1
-1
1
?
Of course not. If you want others to understand your test, you must write your tests in right form.Anyway my program were giving right answer.
Eduard
:lol: it means that I "help" u writing wrong test for which ur program was giving the right answer. :lol:

Posted: Mon Feb 14, 2005 8:41 pm
by Eduard
it means that I "help" u writing wrong test for which ur program was giving the right answer.
I don't understand you.
Answer for this test
Input

Code: Select all

1 
8 
1 
-1 
1 
-100 
1 
-1 
1 
Is this

Output

Code: Select all

The nicest part of route 1 is between stops 1 and 4
And this answer are giving My Ac and old(WA) programs.

offtop

Posted: Mon Feb 14, 2005 9:26 pm
by GVahe
[deleted]

Posted: Tue Feb 15, 2005 9:40 am
by GVahe
OK, now I understand why you don't understand me :wink:
You should read

... writing wrong <- test -> for which ...
not
... writing ( wrong <- test ) -> for which ...

I think it will be clear for you.

507 getting WA please check my I/O

Posted: Tue Mar 15, 2005 12:40 pm
by mohiul alam prince
Hi
I am getting WA in 507.
this is my

INPUT

Code: Select all

20 

6 
1 
0 
0 
0 
1 


6 
1 
0 
0 
1 
-1 

6 
0 
0 
0 
0 
0 

10 
4 
-5 
4 
-3 
4 
4 
-4 
4 
-5 

10 
4 
-5 
4 
-3 
4 
4 
-4 
4 
5 

6 
-1 
1 
-1 
1 
-1 

6 
1 
-1 
1 
-1 
1 

11 
1 
-1 
1 
-1 
1 
-1 
1 
-1 
1 
-1 

12 
1 
-1 
1 
-1 
1 
-1 
1 
-1 
1 
-1 
1
 
10
1
2
4
5
6
7
8
9

2
0

3
1
-1

6
1
1
-100
1
1

7
1
000
0
0
0
0

6
0
0
0
0
-10000

7
1
1
00
0
0
0

2
0

2
-100

13
1
1
1
1
-1
-1
-1
-1
1
1
1
1

6
1
2
3
4
-10
OUTPUT

Code: Select all

The nicest part of route 1 is between stops 1 and 6
The nicest part of route 2 is between stops 1 and 5
Route 3 has no nice parts
The nicest part of route 4 is between stops 3 and 9
The nicest part of route 5 is between stops 3 and 10
The nicest part of route 6 is between stops 2 and 5
The nicest part of route 7 is between stops 1 and 6
The nicest part of route 8 is between stops 1 and 10
The nicest part of route 9 is between stops 1 and 12
The nicest part of route 10 is between stops 1 and 10
Route 11 has no nice parts
The nicest part of route 12 is between stops 1 and 2
The nicest part of route 13 is between stops 1 and 3
The nicest part of route 14 is between stops 1 and 7
Route 15 has no nice parts
The nicest part of route 16 is between stops 1 and 7
Route 17 has no nice parts
Route 18 has no nice parts
The nicest part of route 19 is between stops 1 and 13
The nicest part of route 20 is between stops 1 and 5
why i am getting WA :(

Posted: Wed Mar 16, 2005 12:18 pm
by mohiul alam prince
Hi
I have found my mistake.and got AC :D
thanks

MAP

507 WA!

Posted: Mon May 23, 2005 4:25 am
by midra
I don't understand Why I get wa!
Maybe my algorithm is wrong, or maybe there is some tricky input
here is my code:

Code: Select all

#include <stdio.h>
int s[20003];
max_subsequence(int r,int t){
  int i,j=0,max[20003],start[20003],res=1,st=-1,en=-1;
  start[0]=1;
  for(i=1;i<r;i++){
    if(max[i-1]>=0){
       max[i]+=max[i-1]+s[i];
       start[i]=start[i-1];
    }
    else{
       max[i]+=s[i];
       start[i]=i;
    }
  }
  for(i=r-1;i>0;i--){
      if(max[i]>res){
         res=max[i];
         st=start[i];
         en=i+1;
      }
      else if (max[i]==res){
         if((i+1-start[i])>=(en-st)){
           st=start[i];
           en=i+1;
         }
      }
  }
  if(st==-1 && en==-1)
     printf("Route %d has no nice parts\n",t+1);
  else
    printf("The nicest part of route %d is between stops %d and %d\n",t+1,st,en);
  for(i=1;i<=r;i++)
    max[i]=0;  
}

int main(){
  int t,r,i,j;
  scanf("%d",&t);
  for(i=0;i<t;i++){
    scanf("%d",&r);
    for(j=1;j<r;j++)
       scanf("%d",&s[j]);
    max_subsequence(r,i);
  }
  system("PAUSE");
  return 0;
}
if someone can help me I would appreciate!
thanks and bye!

Posted: Mon May 23, 2005 4:42 pm
by mohiul alam prince
Hi midra
try this Input
Input

Code: Select all

9 

6 
1 
0 
0 
0 
1 


6 
1 
0 
0 
1 
-1 

6 
0 
0 
0 
0 
0 

10 
4 
-5 
4 
-3 
4 
4 
-4 
4 
-5 

10 
4 
-5 
4 
-3 
4 
4 
-4 
4 
5 

6 
-1 
1 
-1 
1 
-1 

6 
1 
-1 
1 
-1 
1 

11 
1 
-1 
1 
-1 
1 
-1 
1 
-1 
1 
-1 

12 
1 
-1 
1 
-1 
1 
-1 
1 
-1 
1 
-1 
1

Output

Code: Select all

The nicest part of route 1 is between stops 1 and 6 
The nicest part of route 2 is between stops 1 and 5 
Route 3 has no nice parts 
The nicest part of route 4 is between stops 3 and 9 
The nicest part of route 5 is between stops 3 and 10 
The nicest part of route 6 is between stops 2 and 5 
The nicest part of route 7 is between stops 1 and 6 
The nicest part of route 8 is between stops 1 and 10 
The nicest part of route 9 is between stops 1 and 12
thanks
MAP

Posted: Tue May 24, 2005 5:48 am
by midra
thanks for your help!
but I get the right outputs for your samples
thanks anyway
byee

Posted: Tue May 24, 2005 11:39 am
by mohiul alam prince
Hi Midra
i have compiled ur code in Microsort Visual c++ 6.0
but i have changed ur code just //system("PAUSE"); this part but it
give's this output

Code: Select all

Route 1 has no nice parts
Route 2 has no nice parts
Route 3 has no nice parts
Route 4 has no nice parts
Route 5 has no nice parts
Route 6 has no nice parts
Route 7 has no nice parts
Route 8 has no nice parts
Route 9 has no nice parts
thanks
MAP

Posted: Tue May 24, 2005 2:50 pm
by Iwashere
I get the correct output when I compiled the program in TC.

Posted: Tue May 24, 2005 4:26 pm
by mohiul alam prince
Hi midra
try this one

Code: Select all

1
10
20000
20000
20000
20000
20000
20000
20000
20000
20000
your programm gives

Code: Select all

The nicest part of route 1 is between stops 1 and 2
Thanks
MAP