結果

問題 No.1439 Let's Compare!!!!
ユーザー 小野寺健小野寺健
提出日時 2021-05-14 20:45:03
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,566 bytes
コンパイル時間 4,403 ms
コンパイル使用メモリ 88,280 KB
実行使用メモリ 77,520 KB
最終ジャッジ日時 2024-04-09 23:32:21
合計ジャッジ時間 11,161 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
59,952 KB
testcase_01 AC 140 ms
54,244 KB
testcase_02 AC 130 ms
54,120 KB
testcase_03 WA -
testcase_04 AC 162 ms
54,436 KB
testcase_05 WA -
testcase_06 AC 137 ms
54,308 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

public class No1439 {
	
	private static int[] S, T;
	private static int N, D;
	private static List<Integer> 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 = new ArrayList<Integer>();
		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;
				} else {
					Diff.add(cs > ct ? i+1 : -i-1);
				}
			}
		}
		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;
		} else if (x == Math.abs(D)) {
			if (S[x-1] != T[x-1]) {
				D = S[x-1] > T[x-1] ? x : -x;
			} else if (Diff.size() > 0) {
				D = Diff.remove(0);
			} else {
				D = 0;
			}
		} else {
			Diff.add(S[x-1] > T[x-1] ? x : -x);
			Diff.sort((a, b) -> Math.abs(a) - Math.abs(b));
		}
	}
}
0