結果

問題 No.2030 Googol Strings
ユーザー 👑 ygussanyygussany
提出日時 2022-07-24 10:10:54
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 936 bytes
コンパイル時間 1,092 ms
コンパイル使用メモリ 28,332 KB
実行使用メモリ 7,608 KB
最終ジャッジ日時 2023-10-13 19:48:41
合計ジャッジ時間 4,398 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,352 KB
testcase_01 AC 5 ms
4,352 KB
testcase_02 AC 5 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 7 ms
4,352 KB
testcase_05 AC 4 ms
4,352 KB
testcase_06 AC 11 ms
6,148 KB
testcase_07 AC 14 ms
7,608 KB
testcase_08 AC 15 ms
7,556 KB
testcase_09 AC 7 ms
4,352 KB
testcase_10 AC 7 ms
4,352 KB
testcase_11 AC 7 ms
4,352 KB
testcase_12 AC 10 ms
4,352 KB
testcase_13 WA -
testcase_14 AC 6 ms
4,348 KB
testcase_15 WA -
testcase_16 AC 11 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int lex_smaller(char s1[], char s2[])
{
	int i;
	for (i = 0; s1[i] != 0 && s2[i] != 0; i++) {
		if (s1[i] < s2[i]) return 1;
		else if (s1[i] > s2[i]) return -1;
	}
	if (s1[i] == s2[i]) return 0;
	else if (s1[i] == 0) return 1;
	else return -1;
}

char solve(char x[], char y[])
{
	int i, j;
	static char xx[2000001], yy[2000001];
	for (i = 0, j = 0; x[j] != 0; i++, j++) xx[i] = x[j];
	for (j = 0; y[j] != 0; i++, j++) xx[i] = y[j];
	for (i = 0, j = 0; y[j] != 0; i++, j++) yy[i] = y[j];
	for (j = 0; x[j] != 0; i++, j++) yy[i] = x[j];
	
	int res = lex_smaller(xx, yy);
	if (res < 0) return 'X';
	else if (res > 0) return 'Y';
	for (i = 0; x[i] != 0; i++);
	for (j = 0; y[j] != 0; j++);
	if (i > j) return 'X';
	else return 'Y';
}

int main()
{
	int T;
	char x[1000001], y[1000001];
	scanf("%d", &T);
	while (T--) {
		scanf("%s", x);
		scanf("%s", y);
		printf("%c\n", solve(x, y));
	}
	fflush(stdout);
	return 0;
}
0