結果

問題 No.1439 Let's Compare!!!!
ユーザー 小野寺健小野寺健
提出日時 2021-05-14 22:19:34
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,658 bytes
コンパイル時間 4,132 ms
コンパイル使用メモリ 80,096 KB
実行使用メモリ 74,272 KB
最終ジャッジ日時 2024-04-10 00:45:07
合計ジャッジ時間 28,656 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
53,992 KB
testcase_01 AC 138 ms
54,136 KB
testcase_02 AC 128 ms
53,920 KB
testcase_03 AC 142 ms
54,180 KB
testcase_04 AC 173 ms
54,320 KB
testcase_05 AC 157 ms
54,180 KB
testcase_06 AC 136 ms
54,264 KB
testcase_07 AC 322 ms
58,892 KB
testcase_08 AC 381 ms
59,216 KB
testcase_09 AC 280 ms
58,268 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;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

public class No1439 {
	
	private static int[] S, T;
	private static int N, D;
	private static boolean A;
	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 = i+1;
					A = S[i] > T[i];
				} else {
					Diff.add(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 (A) {
				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 < D) {
			if (D != 0) {
				Diff.add(0, D);
			}
			D = x;
			A = S[x-1] > T[x-1];
		} else if (x == D) {
			if (S[x-1] != T[x-1]) {
				D = x;
				A = S[x-1] > T[x-1];
			} else if (Diff.size() > 0) {
				D = Diff.remove(0);
				A = S[D-1] > T[D-1];
			} else {
				D = 0;
			}
		} else {
			int i = Collections.binarySearch(Diff, x);
			if (i < 0) {
				Diff.add(-i-1, x);
			}
		}
	}
}
0