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怎么提交啊?

Posted by shadowsong at 2009-04-16 09:35:37 on Problem 1088
测了几组数据, 输出结果没问题,时间还可以。提交时总是出现下面的Compile Error:
----------------------------------------------------------------
Main.java:4: class skier is public, should be declared in a file named skier.java
public class skier
       ^
1 error
----------------------------------------------------------------
我是用java写的,不知道怎么提交啊。在自己电脑上能正常运行。求高人指点,代码如下:

import java.io.*;
import java.util.*;

public class skier
{
	static int m, n;
	static int [][] height;
	static int [][]longest;
	static int [] dx=new int []{1,0,-1,0};
	static int [] dy=new int []{0,1,0,-1};

	static Boolean avail( int y, int x ){
		if( x>=1 && x<=m && y>=1 && y<=n ){
			return true;
		}
		return false;
	}

	static void f( int y, int x ){
		int yy,xx, k,tmp;
		for( k=0; k<=3; k++ ){
			yy=y+dy[k];
			xx=x+dx[k];
			if( avail(yy,xx) ){
				if( height[yy][xx]<height[y][x] ){
					tmp=longest[y][x]+1;
					if( longest[yy][xx]<tmp ){
						longest[yy][xx]=tmp;
						f(yy,xx);
					}
				}
			}
		}
	}

	public static void main(String [] args) throws IOException {
		Scanner in=new Scanner(System.in);
		int y,x,j,i,big=-1;

		try{
			n=in.nextInt();
			m=in.nextInt();
			height=new int [n+1][m+1];
			longest=new int [n+1][m+1];
			for( y=1; y<=n; y++ )
				for( x=1; x<=m; x++ ){
				height[y][x]=in.nextInt();
			}


		} catch (Exception e){
			System.out.println("Wrong input: "+e);
		}

		for( y=1; y<=n; y++ )
			for( x=1; x<=m; x++ ){
			f(y,x);
			for( j=1; j<=n; j++){
				for( i=1; i<=m; i++ ){
					if( big<longest[j][i] ){
						big=longest[j][i];
					}
				}
			}
			for( j=1; j<=n; j++ )
				for( i=1; i<=m; i++ )
					longest[j][i]=0;
		}

		System.out.print(big+1);
	}
}

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