can you please why this code is having run time error???
this problem is from today's contest ....
| № | Пользователь | Рейтинг |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3382 |
| 6 | strapple | 3360 |
| 7 | Um_nik | 3354 |
| 8 | squareOf105 | 3348 |
| 9 | maroonrk | 3312 |
| 10 | idontwannadothis…e | 3191 |
| Страны | Города | Организации | Всё → |
| № | Пользователь | Вклад |
|---|---|---|
| 1 | Qingyu | 155 |
| 2 | nik_exists | 151 |
| 3 | maspy | 149 |
| 4 | AmShZ | 145 |
| 5 | Um_nik | 143 |
| 6 | Errichto | 139 |
| 7 | BledDest | 136 |
| 8 | adamant | 134 |
| 9 | maroonrk | 132 |
| 10 | cry | 130 |
can you please why this code is having run time error???
this problem is from today's contest ....
Can anyone provide me a good source to learn about minimum spanning tree in a directed graph.The sources I found in the internet were very complex...
My c++ solution got accepted. But same process for java causing memory limit exceeded error. can any one explain ??? it's a segment tree problem . I am just switching my language from cpp to java. but i am facing problem while submitting in different on line judges. As in this case same code in c++ got accepted.
Any tips to solve problem in java will definitely help me. I am in great danger.
my code
import java.util.*;
class segmnetTree {
int [] array, segarray;
segmnet()
{
array=new int[100001];
segarray=new int[400001];
}
int left(int n)
{
return 2*n;
}
int right( int n)
{
return 2*n+1;
}
void brmq(int p, int l, int r)
{
if(l==r)
{
segarray[p]=array[l];
return;
}
brmq(left(p),l,(l+r)/2);
brmq(right(p),(l+r)/2+1,r);
segarray[p]=Math.min(segarray[left(p)],segarray[right(p)]);
}
int rmq( int p,int l, int r, int i, int j)
{
if(i>r || j<l) return -1; // MAXXXX or set it in a way to understand
else if(l>=i && r<=j) return segarray[p];
int a1=rmq( left(p), l,(l+r)/2, i,j);
int a2=rmq( right(p), (l+r)/2+1 , r , i,j);
if(a1==-1) return a2;
if(a2==-1) return a1;
else return Math.min(a1,a2);
}}
public class SegmentTree {
public static void main(String[] args) {
segmnet s1=new segmnet();
Scanner sin=new Scanner(System.in);
int cas=sin.nextInt();
for( int cno=1; cno<=cas;cno++)
{
int n,q;
n=sin.nextInt();
q=sin.nextInt();
for( int m=1;m<=n;m++)
{
s1.array[m]=sin.nextInt();
}
s1.brmq(1,1,n);
System.out.println("Case "+cno+":");
for( int m=0;m<q;m++)
{
int i,j;
i=sin.nextInt();
j=sin.nextInt();
System.out.println(s1.rmq(1,1,n,i,j));
}
}
}}
| Название |
|---|


