結果

問題 No.3757 Happy End
コンテスト
ユーザー simasima_71
提出日時 2026-10-09 21:25:22
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 6 ms / 2,000 ms
+ 375µs
コード長 1,116 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,451 ms
コンパイル使用メモリ 249,964 KB
実行使用メモリ 9,868 KB
最終ジャッジ日時 2026-10-09 21:25:31
合計ジャッジ時間 4,838 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pl = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
template<class T> using pq_ = priority_queue<T, vector<T>, greater<T>>;
#define sz(x) (int)(x).size()
typedef pair<int, int> pii;
using mint=modint998244353;
// g++ a.cpp -std=c++23 -I.
// g++ -std=c++23 -I. a.cpp -o main
// g++ -std=c++23 -I. anaive.cpp -o naive
// g++ -std=c++23 -I. agene.cpp -o gene



int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    string r="HAPPY";
    ll ans=0;
    rep(i,n-5,n){
        if(s[i]!=r[i-(n-5)]){
            s[i]=r[i-(n-5)];
            ans++;
        }
    }
    rep(i,0,n-5){
        if(s.substr(i,5)==r){
            ans++;
        }
    }
    cout<<ans<<endl;
}
0