C - Online Judge,java半实现

package stringTrain;

import java.util.Scanner;
//没有实现读入里面按照“start”和“end”来分
public class problemC {
	public static String pure(char a[]) {
		String s = "";
		for (int i = 0; i < a.length; i++) {
			if (a[i] != ' ') {
				s += a[i];
			}
		}
		return s;
	}

	public static boolean same(char a[], char a2[]) {
		int y = 0;
		if (a.length == a2.length) {
			for (int i = 0; i < a2.length; i++) {
				if (a[i] != a2[i]) {
					y = 0;
					break;
				}
			}

		} else {
			y = 0;
		}

		if (y == 0) {
			return false;
		} else {
			return true;
		} // accept
	}

	public static boolean same2(char a[], char a2[]) {
		int y = 0;
		String s1 = pure(a);
		String s2 = pure(a2);
		char a3[] = s1.toCharArray();
		char a4[] = s1.toCharArray();

		if (same(a3, a4)) {
			y = 1;
		}
		if (y == 0) {
			return false;
		} else {
			return true;
		} // "Presentation Error"
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		String s1, cor, s2, s3, user, s4 = "";
		for (int i = 0; i < t; i++) {
			s1 = in.nextLine();
			cor = in.nextLine();
			s2 = in.nextLine();
			s3 = in.nextLine();
			user = in.nextLine();
			s4 = in.nextLine();
			char a[] = cor.toCharArray();
			char a2[] = user.toCharArray();
			if (same(a, a2)) {
				System.out.println("Accepted");
			} else {
				if (same2(a, a2)) {
					System.out.println("Presentation Error");
				} else {
					System.out.println("Wrong Answer");
				}
			}
		}

	}

}

Ignatius is building an Online Judge, now he has worked out all the problems except the Judge System. The system has to read data from correct output file and user’s result file, then the system compare the two files. If the two files are absolutly same, then the Judge System return “Accepted”, else if the only differences between the two files are spaces(’ ‘), tabs(’\t’), or enters(’\n’), the Judge System should return “Presentation Error”, else the system will return “Wrong Answer”.

上一篇:C2. Increasing Subsequence (hard version)(水)


下一篇:Online Judge Web端设计