結果

問題 No.273 回文分解
ユーザー bal4ubal4u
提出日時 2019-04-18 20:27:12
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 809 bytes
コンパイル時間 1,746 ms
コンパイル使用メモリ 30,352 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-23 16:23:09
合計ジャッジ時間 3,760 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 WA -
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 WA -
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 WA -
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 1 ms
4,348 KB
testcase_30 AC 1 ms
4,348 KB
testcase_31 WA -
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 1 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'ins':
main.c:7:14: warning: implicit declaration of function 'getchar_unlocked' [-Wimplicit-function-declaration]
    7 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:15:28: note: in expansion of macro 'gc'
   15 |         do *s++ = '_', c = gc(), *s++ = c;
      |                            ^~

ソースコード

diff #

// yukicoder: No.273 回文分解
// 2019.4.18 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int ins(char *s)  // 文字列の入力 スペース以下の文字で入力終了
{
	char *p = s;
	char c;
	do *s++ = '_', c = gc(), *s++ = c;
	while (c > ' ');
	*--s = 0;
	return s - p;
}

int r[200];
char s[200];

void manacher(char *s, int w)
{
	int i = 0, j = 0, k = 1;
	while (i < w) {
		while (i - j >= 0 && i + j < w && s[i - j] == s[i + j]) j++;
		r[i] = j;
		while (i - k >= 0 && i + k < w && k + r[i - k] < j) {
			r[i + k] = r[i - k], k++;
		}
		i += k; j -= k;
	}
}

int main()
{
	int i, max = 0, w = ins(s);
	manacher(s, w);
	for (i = 0; i < w; i++) {
		if (r[i] > max) max = r[i];
	}
	if (w <= 2*max) max--;
	printf("%d\n", max-1);
	return 0;
}
0