結果

問題 No.2454 Former < Latter
ユーザー t98slider
提出日時 2023-09-15 00:24:55
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 450 bytes
コンパイル時間 3,601 ms
コンパイル使用メモリ 228,888 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-02 06:30:48
合計ジャッジ時間 4,711 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T, n, ans;
    cin >> T;
    while(T--){
        string s;
        cin >> n >> s;
        s += '`';
        auto za = atcoder::z_algorithm(s);
        ans = 0;
        for(int i = 1; i < n; i++){
            ans += za[i] >= i ? i < za[i] : s[za[i]] < s[i + za[i]];
        }
        cout << ans << '\n';
    }
}
0