Submission #65746940


Source Code Expand

Copy
#include <stdio.h>
#include <inttypes.h>
#include <limits.h>
char S[114514];
int cnt[1 << CHAR_BIT];
int main(void) {
int i;
int ans = 0;
int kisuu = 0;
if (scanf("%114513s", S) != 1) return 1;
for (i = 0; S[i] != '\0'; i++) {
cnt[(unsigned char)S[i]]++;
}
for (i = 0; i < (1 << CHAR_BIT); i++) {
ans += cnt[i] & ~1;
kisuu += cnt[i] & 1;
}
if (kisuu > 0) {
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <stdio.h>
#include <inttypes.h>
#include <limits.h>

char S[114514];

int cnt[1 << CHAR_BIT];

int main(void) {
	int i;
	int ans = 0;
	int kisuu = 0;
	if (scanf("%114513s", S) != 1) return 1;
	for (i = 0; S[i] != '\0'; i++) {
		cnt[(unsigned char)S[i]]++;
	}
	for (i = 0; i < (1 << CHAR_BIT); i++) {
		ans += cnt[i] & ~1;
		kisuu += cnt[i] & 1;
	}
	if (kisuu > 0) {
		ans++;
		kisuu--;
	}
	printf("%" PRId64 "\n", (int64_t)ans * ans + kisuu);
	return 0;
}

/*

短いのをいっぱい作るより、長いのを1個作ったほうがいい (多分)
偶数個 → 入れる
奇数個 → 1個は入れ、残りは長さ1

*/

Submission Info

Submission Time
Task G - 回文スコア
User mikecat
Language C (gcc 12.2.0)
Score 400
Code Size 669 Byte
Status AC
Exec Time 1 ms
Memory 1832 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 1
AC × 15
Set Name Test Cases
Sample example01.txt
All example01.txt, subtask_01_01.txt, subtask_01_02.txt, subtask_01_03.txt, subtask_01_04.txt, subtask_01_05.txt, subtask_01_06.txt, subtask_01_07.txt, subtask_01_08.txt, subtask_01_09.txt, subtask_01_10.txt, subtask_01_11.txt, subtask_01_12.txt, subtask_01_13.txt, subtask_01_14.txt
Case Name Status Exec Time Memory
example01.txt AC 1 ms 1740 KB
subtask_01_01.txt AC 0 ms 1564 KB
subtask_01_02.txt AC 1 ms 1740 KB
subtask_01_03.txt AC 0 ms 1728 KB
subtask_01_04.txt AC 1 ms 1672 KB
subtask_01_05.txt AC 0 ms 1564 KB
subtask_01_06.txt AC 1 ms 1672 KB
subtask_01_07.txt AC 0 ms 1596 KB
subtask_01_08.txt AC 1 ms 1832 KB
subtask_01_09.txt AC 1 ms 1780 KB
subtask_01_10.txt AC 1 ms 1636 KB
subtask_01_11.txt AC 0 ms 1616 KB
subtask_01_12.txt AC 0 ms 1616 KB
subtask_01_13.txt AC 0 ms 1724 KB
subtask_01_14.txt AC 0 ms 1744 KB


2025-05-13 (Tue)
07:15:04 +09:00