結果

問題 No.3757 Happy End
コンテスト
ユーザー sdtkwxt
提出日時 2026-10-09 21:29:20
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 7 ms / 2,000 ms
+ 417µs
コード長 851 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,127 ms
コンパイル使用メモリ 354,828 KB
実行使用メモリ 9,904 KB
最終ジャッジ日時 2026-10-09 21:29:45
合計ジャッジ時間 4,357 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
#define CSP2026 using
#define RP namespace
#define PLUSPLUS std
CSP2026 RP PLUSPLUS;
#define debug(x) cout<<"clock="<<clock()<<' '<<#x<<'='<<(x)<<'\n'
//#define getchar getchar_unlocked
using ll=long long;
inline int rd(){int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;for(;isdigit(ch);ch=getchar())x=(x<<3)+(x<<1)+(ch^48);return x*f;}
inline ll rdll(){ll x=0;int f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;for(;isdigit(ch);ch=getchar())x=(x<<3)+(x<<1)+(ch^48);return x*f;}
signed main(){
	int n=rd(),cnt=0;
	string s;cin>>s;
	if(s[n-5]!='H')++cnt,s[n-5]='H';
	if(s[n-4]!='A')++cnt,s[n-4]='A';
	if(s[n-3]!='P')++cnt,s[n-3]='P';
	if(s[n-2]!='P')++cnt,s[n-2]='P';
	if(s[n-1]!='Y')++cnt,s[n-1]='Y';
	for(int i=0;i<n-5;++i)if(s.substr(i,5)=="HAPPY")++cnt;
	cout<<cnt<<'\n';
}
0