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

谁帮我看一下,一直WA,没有用什么高级的东西。感觉思路没错。。。。。。谢谢了

Posted by Kuroro at 2013-01-02 19:21:29 on Problem 3349 and last updated at 2013-01-02 20:31:15
什么高深的东西都没有用。。。。。。一直WA。
思路是 用六个数的和作为key,在key相同的之中找是否存在一样的。
一样的判定是: 
在第一个雪花的字符串str1str1中 找str2和反序str2。

class snowflack{
	int[] flacks;
	int key;
	public snowflack(int[] f) {
		flacks= new int[6];
		key= 0;
		for(int i=0; i<6; i++){
			flacks[i]= f[i];
			key+= f[i];
		}
	}
	public String toString(){
		String str= "";
		for(int i=0; i<6; i++){
			str+= flacks[i];
		}
		return str;
	}
}

class SnowComparator implements Comparator<Object> {
	public final int compare(Object s1, Object s2) {
		return ((snowflack) s1).key- ((snowflack) s2).key;
	}
}

//应该是这个比较函数错了,但是想不出来为什么。。。。。。
	private static boolean check(snowflack s1, snowflack s2) {
			String str1= "";
			str1= s1.toString();
			str1+= str1;
//			System.out.println("str1 "+str1);
			String str2= s2.toString();
//			System.out.println("str2 "+str2);
			String revstr2= reverse(str2);
//			System.out.println("revstr2 "+revstr2);
			if(str1.indexOf(str2)==-1 && str1.indexOf(revstr2)==-1) {
//				System.out.println("f");
				return false;			
			}
			else return true;
	}

	private static String reverse(String str) {
		String revstr= "";
		for(int i=str.length()-1; i>=0; i--)
			revstr+= str.charAt(i);
		return revstr;
	}
}

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