結果

問題 No.2030 Googol Strings
ユーザー tentententen
提出日時 2023-07-24 18:58:33
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,132 bytes
コンパイル時間 2,733 ms
コンパイル使用メモリ 89,828 KB
実行使用メモリ 57,612 KB
最終ジャッジ日時 2024-04-09 02:24:42
合計ジャッジ時間 8,415 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 183 ms
55,224 KB
testcase_01 AC 181 ms
55,984 KB
testcase_02 AC 154 ms
54,436 KB
testcase_03 AC 51 ms
50,088 KB
testcase_04 WA -
testcase_05 AC 215 ms
54,436 KB
testcase_06 AC 218 ms
56,532 KB
testcase_07 AC 264 ms
56,940 KB
testcase_08 AC 249 ms
57,072 KB
testcase_09 AC 284 ms
56,212 KB
testcase_10 AC 290 ms
56,360 KB
testcase_11 AC 281 ms
56,400 KB
testcase_12 AC 207 ms
55,096 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 282 ms
56,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        while (n-- > 0) {
            if (isLarger(sc.next(), sc.next())) {
                sb.append("X\n");
            } else {
                sb.append("Y\n");
            }
        }
        System.out.print(sb);
    }
    
    static boolean isLarger(String a, String b) {
        if (a.length() > b.length()) {
            return !isLarger(b, a);
        }
        for (int i = 0; i < b.length(); i++) {
            if (a.charAt(i % a.length()) < b.charAt(i)) {
                return false;
            } else if (a.charAt(i % a.length()) > b.charAt(i)) {
                return true;
            }
        }
        return false;
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0