結果

問題 No.2030 Googol Strings
ユーザー ks2mks2m
提出日時 2022-08-05 22:28:25
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,165 bytes
コンパイル時間 5,598 ms
コンパイル使用メモリ 73,884 KB
実行使用メモリ 59,984 KB
最終ジャッジ日時 2023-10-13 23:45:50
合計ジャッジ時間 6,469 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 165 ms
55,040 KB
testcase_01 AC 130 ms
55,316 KB
testcase_02 AC 114 ms
54,308 KB
testcase_03 AC 44 ms
49,512 KB
testcase_04 AC 162 ms
55,088 KB
testcase_05 AC 128 ms
55,464 KB
testcase_06 AC 144 ms
56,768 KB
testcase_07 AC 152 ms
56,612 KB
testcase_08 AC 173 ms
55,984 KB
testcase_09 AC 156 ms
55,816 KB
testcase_10 AC 133 ms
56,232 KB
testcase_11 AC 141 ms
55,692 KB
testcase_12 AC 175 ms
55,360 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 174 ms
56,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		PrintWriter pw = new PrintWriter(System.out);
		for (int z = 0; z < t; z++) {
			String x = br.readLine();
			String y = br.readLine();

			if (x.length() == y.length()) {
				if (x.compareTo(y) > 0) {
					pw.println("X");
				} else {
					pw.println("Y");
				}
			} else {
				StringBuilder sbx = new StringBuilder(x);
				StringBuilder sby = new StringBuilder(y);
				while (sbx.length() < sby.length()) {
					sbx.append(x);
				}
				while (sbx.length() > sby.length()) {
					sby.append(y);
				}

				String x2 = sbx.toString();
				String y2 = sby.substring(0, x2.length());
				int cmp = x2.compareTo(y2);
				if (cmp == 0) {
					if (x.length() > y.length()) {
						pw.println("X");
					} else {
						pw.println("Y");
					}
				} else if (cmp > 0) {
					pw.println("X");
				} else {
					pw.println("Y");
				}
			}
		}
		pw.flush();
		br.close();
	}
}
0