結果
| 問題 | No.1439 Let's Compare!!!! | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-05-14 21:55:55 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,667 bytes | 
| コンパイル時間 | 3,877 ms | 
| コンパイル使用メモリ | 79,788 KB | 
| 実行使用メモリ | 77,752 KB | 
| 最終ジャッジ日時 | 2024-10-02 01:10:35 | 
| 合計ジャッジ時間 | 9,755 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 2 WA * 6 TLE * 1 -- * 8 | 
ソースコード
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 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;
				} else {
					Diff.add(i);
				}
			}
		}
		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 (S[D-1] > T[D-1] ) {
				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)) {
			if (D != 0) {
				Diff.add(0, D-1);
			}
			D = x;
		} else if (x == Math.abs(D)) {
			if (S[x-1] != T[x-1]) {
				D = x;
			} else if (Diff.size() > 0) {
				int i = Diff.remove(0);
				D = i;
			} else {
				D = 0;
			}
		} else {
			int i = Diff.indexOf(x);
			if (i >= 0) {
				Diff.set(i, x);
			} else {
				i = Collections.binarySearch(Diff, x);
				i = i >= 0 ? i : -i-1;
				Diff.add(i, x);
			}
		}
	}
}
            
            
            
        