結果

問題 No.1439 Let's Compare!!!!
ユーザー tentententen
提出日時 2024-02-07 13:24:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,110 ms / 2,000 ms
コード長 2,247 bytes
コンパイル時間 3,019 ms
コンパイル使用メモリ 84,652 KB
実行使用メモリ 82,140 KB
最終ジャッジ日時 2024-02-07 13:24:51
合計ジャッジ時間 14,009 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
54,880 KB
testcase_01 AC 86 ms
54,888 KB
testcase_02 AC 85 ms
54,888 KB
testcase_03 AC 86 ms
55,008 KB
testcase_04 AC 96 ms
55,272 KB
testcase_05 AC 90 ms
54,992 KB
testcase_06 AC 89 ms
55,000 KB
testcase_07 AC 195 ms
58,800 KB
testcase_08 AC 235 ms
60,264 KB
testcase_09 AC 175 ms
57,632 KB
testcase_10 AC 1,110 ms
82,072 KB
testcase_11 AC 857 ms
72,192 KB
testcase_12 AC 899 ms
70,628 KB
testcase_13 AC 1,087 ms
82,100 KB
testcase_14 AC 1,065 ms
82,140 KB
testcase_15 AC 824 ms
67,508 KB
testcase_16 AC 660 ms
66,908 KB
testcase_17 AC 659 ms
66,236 KB
testcase_18 AC 573 ms
65,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        char[][] strings = new char[2][];
        for (int i = 0; i < 2; i++) {
            strings[i] = sc.next().toCharArray();
        }
        Map<String, Integer> idxes = Map.of("S", 0, "T", 1);
        TreeSet<Integer> diff = IntStream.range(0, n).filter(i -> strings[0][i] != strings[1][i])
            .mapToObj(i -> Integer.valueOf(i)).collect(Collectors.toCollection(TreeSet::new));
        int q = sc.nextInt();
        String result = IntStream.range(0, q).mapToObj(i -> {
            int x = idxes.get(sc.next());
            int positon = sc.nextInt() - 1;
            char c = (char)(sc.nextInt() + '0');
            strings[x][positon] = c;
            if (strings[0][positon] == strings[1][positon]) {
                diff.remove(positon);
            } else {
                diff.add(positon);
            }
            if (diff.size() == 0) {
                return "=";
            } else if (strings[0][diff.first()] < strings[1][diff.first()]) {
                return "<";
            } else {
                return ">";
            }
        }).collect(Collectors.joining("\n"));
        System.out.println(result);
    }
}
class Scanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
        } catch (Exception e) {
            
        }
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
    
    public String next() {
        try {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return st.nextToken();
        }
    }
    
}
0