結果

問題 No.2030 Googol Strings
ユーザー 👑 ygussanyygussany
提出日時 2022-07-24 10:11:39
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 960 bytes
コンパイル時間 487 ms
コンパイル使用メモリ 28,632 KB
実行使用メモリ 7,696 KB
最終ジャッジ日時 2023-09-20 08:17:02
合計ジャッジ時間 3,332 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
4,380 KB
testcase_01 AC 5 ms
4,380 KB
testcase_02 AC 5 ms
4,384 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 8 ms
4,380 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 11 ms
6,276 KB
testcase_07 AC 15 ms
7,584 KB
testcase_08 AC 15 ms
7,696 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 7 ms
4,384 KB
testcase_11 AC 7 ms
4,384 KB
testcase_12 AC 9 ms
4,380 KB
testcase_13 AC 10 ms
4,384 KB
testcase_14 AC 6 ms
4,384 KB
testcase_15 AC 11 ms
4,388 KB
testcase_16 AC 11 ms
4,380 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];
	xx[i] = 0;
	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];
	yy[i] = 0;
	
	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