結果
| 問題 | No.3757 Happy End |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2026-10-10 18:12:13 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 3 ms / 2,000 ms |
| + 11µs | |
| コード長 | 649 bytes |
| 記録 | |
| コンパイル時間 | 161 ms |
| コンパイル使用メモリ | 53,420 KB |
| 実行使用メモリ | 9,844 KB |
| 最終ジャッジ日時 | 2026-10-10 18:12:19 |
| 合計ジャッジ時間 | 2,959 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 47 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 3757.cc: No.3757 Happy End - yukicoder
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 300000;
const int L = 5;
const char p[] = "HAPPY";
/* typedef */
/* global variables */
char s[MAX_N + 4];
/* subroutines */
/* main */
int main() {
int n;
scanf("%d%s", &n, s);
int sum = 0;
for (int i = 0; i < L; i++)
if (s[n - L + i] != p[i]) sum++;
copy(p, p + L, s + (n - L));
for (int i = 0; i < n - L;) {
if (! strncmp(s + i, p, L)) s[i + L - 1] = 'Z', sum++, i += L;
else i++;
}
printf("%d\n", sum);
return 0;
}
tnakao0123