結果

問題 No.2030 Googol Strings
ユーザー ks2mks2m
提出日時 2022-08-05 22:34:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 243 ms / 2,000 ms
コード長 1,203 bytes
コンパイル時間 2,088 ms
コンパイル使用メモリ 73,800 KB
実行使用メモリ 64,488 KB
最終ジャッジ日時 2023-10-13 23:56:09
合計ジャッジ時間 6,108 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 183 ms
55,752 KB
testcase_01 AC 135 ms
55,472 KB
testcase_02 AC 116 ms
54,104 KB
testcase_03 AC 44 ms
49,152 KB
testcase_04 AC 182 ms
55,040 KB
testcase_05 AC 130 ms
55,004 KB
testcase_06 AC 166 ms
64,488 KB
testcase_07 AC 157 ms
56,776 KB
testcase_08 AC 167 ms
56,364 KB
testcase_09 AC 151 ms
54,460 KB
testcase_10 AC 151 ms
54,452 KB
testcase_11 AC 151 ms
54,128 KB
testcase_12 AC 194 ms
55,004 KB
testcase_13 AC 232 ms
55,800 KB
testcase_14 AC 146 ms
53,368 KB
testcase_15 AC 243 ms
59,284 KB
testcase_16 AC 180 ms
59,072 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);
				sbx.append(x);
				sby.append(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