結果
問題 |
No.1439 Let's Compare!!!!
|
ユーザー |
|
提出日時 | 2021-05-14 18:01:22 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,230 bytes |
コンパイル時間 | 3,630 ms |
コンパイル使用メモリ | 78,076 KB |
実行使用メモリ | 69,524 KB |
最終ジャッジ日時 | 2024-10-01 22:03:47 |
合計ジャッジ時間 | 21,639 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 4 WA * 13 |
ソースコード
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('='); } } } 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 (x < Math.abs(D)) { D = S[x-1] > T[x-1] ? x : -1; } else if (x == Math.abs(D)) { D = 0; for (int i=x-1; i < N; i++) { if (S[i] != T[i]) { D = S[i] > T[i] ? i+1 : -i-1; break; } } } } }