結果
| 問題 | No.3757 Happy End |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-09 22:38:51 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 6 ms / 2,000 ms |
| + 13µs | |
| コード長 | 1,372 bytes |
| 記録 | |
| コンパイル時間 | 2,904 ms |
| コンパイル使用メモリ | 354,976 KB |
| 実行使用メモリ | 9,904 KB |
| 最終ジャッジ日時 | 2026-10-09 22:39:05 |
| 合計ジャッジ時間 | 4,442 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 47 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define nall(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Yes cout << "Yes" << "\n"
#define No cout << "No" << "\n"
template<typename T,typename U>inline bool chmax(T&a,U b){if(a<b){a=b;return 1;}return 0;}
template<typename T,typename U>inline bool chmin(T&a,U b){if(a>b){a=b;return 1;}return 0;}
using ll = long long;
using ull = unsigned long long;
using P = pair<ll,ll>;
const ll inf = (2e9)+2026;
const ll INF = (1e18)+2026;
const ll dx[] = {0,1,0,-1,1,1,-1,-1};
const ll dy[] = {1,0,-1,0,1,-1,1,-1};
//#include <atcoder/all>
//using namespace atcoder;
//using mint = atcoder::modint998244353;
using T = tuple<ll,ll,ll>;
ll testcase(){
ll n; cin >> n;
string s; cin >> s;
string t = "HAPPY";
ll ans = 0;
for(ll i=n-5,j=0; i<n; i++, j++){
ans += s[i]!=t[j];
s[i] = t[j];
}
for(ll i=0; i+5<n; i++){
string sub = s.substr(i,5);
if(sub == t){
s[i] = 'B';
ans ++;
}
}
cout << ans << endl;
return 0;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
//cout << fixed << setprecision(15);
int t=1;
#ifdef LOCAL
t=1;
#else
t=1;
#endif
//cin >> t;
while(t--)
testcase();
return 0;
}