結果

問題 No.588 空白と回文
ユーザー bal4ubal4u
提出日時 2019-05-11 07:33:47
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 795 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 29,096 KB
実行使用メモリ 5,048 KB
最終ジャッジ日時 2023-09-14 18:06:00
合計ジャッジ時間 1,240 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,048 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 0 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 0 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 0 ms
4,376 KB
testcase_08 AC 0 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 0 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 0 ms
4,376 KB
testcase_19 AC 1 ms
4,384 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 0 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘ins’ 内:
main.c:7:14: 警告: 関数 ‘getchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    7 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:15:17: 備考: in expansion of macro ‘gc’
   15 |         do *s = gc();
      |                 ^~

ソースコード

diff #

// yukicoder: No.588 空白と回文
// 2019.5.11 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int ins(char *s)  // 文字列の入力 スペース以下の文字で入力終了
{
	char *p = s;
	do *s = gc();
	while (*s++ > ' ');
	*--s = 0;
	return s - p;
}

int f[2005];
char S[1002];
int p[128][1002], w[128];

void calc(int c) {
	int i, j;
	for (i = 0; i < w[c]; i++) {
		for (j = w[c]-1; j > i; j--) f[p[c][i] + p[c][j]]++;
	}
}

int main()
{
	int i, k, len, ans;
	
	len = ins(S);
	for (i = 0; i < len; i++) p[S[i]][w[S[i]]++] = i;
	for (i = '0'; i <= 'z'; i++) if (w[i] > 1) calc(i);
	ans = 0; len <<= 1; for (i = 0; i < len; i++) {
		k = 1+(f[i]<<1);
		if (i & 1) k--;
		if (k > ans) ans = k;
	}
	printf("%d\n", ans);
	return 0;
}
0