結果

問題 No.1439 Let's Compare!!!!
ユーザー 小野寺健小野寺健
提出日時 2021-05-14 23:01:28
言語 Java21
(openjdk 21)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,439 bytes
コンパイル時間 3,778 ms
コンパイル使用メモリ 77,744 KB
実行使用メモリ 75,440 KB
最終ジャッジ日時 2024-04-10 02:21:00
合計ジャッジ時間 26,216 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
54,100 KB
testcase_01 AC 143 ms
54,224 KB
testcase_02 AC 138 ms
53,880 KB
testcase_03 AC 151 ms
54,084 KB
testcase_04 AC 157 ms
54,240 KB
testcase_05 AC 149 ms
54,020 KB
testcase_06 AC 140 ms
53,976 KB
testcase_07 AC 324 ms
58,484 KB
testcase_08 AC 387 ms
59,544 KB
testcase_09 AC 275 ms
58,176 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No1439 {
	
	private static int[] S, T;
	private static int N, D;
	private static int Diff;

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		N = scan.nextInt();
		String s = scan.next();
		String t = scan.next();
		int Q = scan.nextInt();
		S = new int[N];
		T = new int[N];
		D = 0;
		Diff = 0;
		for (int i=0; i < N; i++) {
			int cs = s.charAt(i) - '0';
			int ct = t.charAt(i) - '0';
			S[i] = cs;
			T[i] = ct;
			if (cs != ct) {
				if (D == 0) {
					D = cs > ct ? i+1 : -i-1;
				}
				Diff++;
			}
		}
		for (int i=0; i < Q; i++) {
			String c = scan.next();
			int x = scan.nextInt();
			int y = scan.nextInt();
			review(c.charAt(0), x, y);
			if (D > 0) {
				System.out.println('>');
			} else if (D < 0) {
				System.out.println('<');
			} else {
				System.out.println('=');
			}
		}
		scan.close();
	}
	private static void review(char c, int x, int y) {
		if (c == 'S') {
			if (S[x-1] == y) {
				return;
			}
			S[x-1] = y;
		} else {
			if (T[x-1] == y) {
				return;
			}
			T[x-1] = y;
		}
		if (D == 0 || x < Math.abs(D)) {
			D = S[x-1] > T[x-1] ? x : -x;
			Diff++;
		} else if (x == Math.abs(D)) {
			D = 0;
			if (S[x-1] == T[x-1]) { 
				Diff--;
				if (Diff == 0) {
					return;
				}
			}
			for (int i=x-1; i < N; i++) {
				if (S[i] != T[i]) {
					D = S[i] > T[i] ? i+1 : -i-1;
					break;
				}
			}
		} else {
			Diff++;
		}
	}
}
0