結果

問題 No.588 空白と回文
ユーザー bal4ubal4u
提出日時 2019-05-11 07:19:31
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 802 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 29,040 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-14 18:05:48
合計ジャッジ時間 1,455 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 0 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 0 ms
4,384 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 WA -
testcase_12 AC 1 ms
4,376 KB
testcase_13 WA -
testcase_14 AC 1 ms
4,380 KB
testcase_15 WA -
testcase_16 AC 0 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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[1002];
char S[1002];
int p[128][1002], w[128];

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

int main()
{
	int i, 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; for (i = 0; i < len; i++) {
		if (f[i] > ans) ans = f[i];
	}
	printf("%d\n", 1+(ans<<1));
	return 0;
}
0