結果

問題 No.1439 Let's Compare!!!!
ユーザー 小野寺健小野寺健
提出日時 2021-05-14 18:21:42
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,328 bytes
コンパイル時間 3,357 ms
コンパイル使用メモリ 78,428 KB
実行使用メモリ 78,048 KB
最終ジャッジ日時 2024-04-09 21:53:46
合計ジャッジ時間 22,717 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
54,100 KB
testcase_01 AC 125 ms
54,536 KB
testcase_02 AC 108 ms
52,772 KB
testcase_03 AC 131 ms
54,180 KB
testcase_04 AC 147 ms
54,076 KB
testcase_05 AC 127 ms
54,104 KB
testcase_06 AC 120 ms
53,972 KB
testcase_07 AC 300 ms
58,568 KB
testcase_08 AC 364 ms
59,336 KB
testcase_09 AC 264 ms
58,056 KB
testcase_10 TLE -
testcase_11 AC 1,887 ms
69,548 KB
testcase_12 AC 1,671 ms
73,040 KB
testcase_13 AC 1,852 ms
71,224 KB
testcase_14 AC 1,978 ms
71,196 KB
testcase_15 AC 1,792 ms
69,808 KB
testcase_16 AC 1,928 ms
69,748 KB
testcase_17 TLE -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

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

	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;
		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 (D == 0 && cs != ct) {
				D = 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)) {
			D = 0;
			if (Arrays.equals(S, T)) {
				return;
			}
			for (int i=x-1; i < N; i++) {
				if (S[i] != T[i]) {
					D = S[i] > T[i] ? i+1 : -i-1;
					break;
				}
			}
		}
	}
}
0