結果

問題 No.2030 Googol Strings
ユーザー tentententen
提出日時 2024-04-02 15:18:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 323 ms / 2,000 ms
コード長 1,633 bytes
コンパイル時間 2,276 ms
コンパイル使用メモリ 78,764 KB
実行使用メモリ 60,472 KB
最終ジャッジ日時 2024-04-02 15:18:18
合計ジャッジ時間 8,459 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 180 ms
58,824 KB
testcase_01 AC 178 ms
59,312 KB
testcase_02 AC 155 ms
57,836 KB
testcase_03 AC 54 ms
53,984 KB
testcase_04 AC 175 ms
58,560 KB
testcase_05 AC 208 ms
57,536 KB
testcase_06 AC 231 ms
59,908 KB
testcase_07 AC 260 ms
60,116 KB
testcase_08 AC 248 ms
60,212 KB
testcase_09 AC 236 ms
59,556 KB
testcase_10 AC 272 ms
59,508 KB
testcase_11 AC 232 ms
59,656 KB
testcase_12 AC 231 ms
59,536 KB
testcase_13 AC 266 ms
59,212 KB
testcase_14 AC 240 ms
59,672 KB
testcase_15 AC 323 ms
60,396 KB
testcase_16 AC 288 ms
60,472 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();
        StringBuilder sb = new StringBuilder();
        while (n-- > 0) {
            sb.append(compare(sc.next(), sc.next()) < 0 ? "Y\n" : "X\n");
        }
        System.out.print(sb);
    }
    
    static int compare(String a, String b) {
        for (int i = 0; i < Math.max(a.length(), b.length()) * 2; i++) {
            if (a.charAt(i % a.length()) != b.charAt(i % b.length())) {
                return a.charAt(i % a.length()) - b.charAt(i % b.length());
            }
        }
        return a.length() - b.length();
    }
}
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