Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Java - why TLE ? please help

Posted by javaWarrior at 2007-04-05 06:30:13 on Problem 2777
import java.io.*;
import java.util.*;

class Main {
	
public static void main(String[] args)throws IOException {
		
   	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));	
	//BufferedReader br=new BufferedReader(new FileReader("in.txt"));	
	
	StringBuffer s= new StringBuffer();
	String linea;
	StringTokenizer st;	
	int L,T,O,A,B,C,i,j,count;
	int[]board;
	boolean statecolors[];
	
	while((linea=br.readLine())!=null)
	{
		
	st=new StringTokenizer(linea);
	
	L=new Integer(st.nextToken());
	T=new Integer(st.nextToken());
	O=new Integer(st.nextToken());
	
	board=new int[L+1];
				
	for(i=1;i<=O;i++)
	{
		
	st=new StringTokenizer(br.readLine());
	
	
    switch(st.countTokens())
	{
		
	case 4:
		
	st.nextToken();
	
	A=new Integer(st.nextToken());
	B=new Integer(st.nextToken());
	C=new Integer(st.nextToken());
	
	Arrays.fill(board,Math.min(A,B),Math.max(A,B)+1,C-1);
	
	break;
	
	case 3:
		
	st.nextToken();
	
	A=new Integer(st.nextToken());
	B=new Integer(st.nextToken());	
	
	statecolors=new boolean[T+1];
	
	count=0;
				
	for(j=Math.min(A,B);j<=Math.max(A,B);j++)
	
	if(!statecolors[board[j]]){
	statecolors[board[j]]=true;		
	count++;	
	}
	    
	s.append(count+"\n");
	break;
	
	}
	}	
	}
	
System.out.println(s);

}

}			

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator