結果
問題 | No.2454 Former < Latter |
ユーザー |
![]() |
提出日時 | 2023-09-01 21:29:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 264 ms / 2,000 ms |
コード長 | 510 bytes |
コンパイル時間 | 2,815 ms |
コンパイル使用メモリ | 214,604 KB |
最終ジャッジ日時 | 2025-02-16 16:16:51 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/string> using namespace std; int main(){ int T; cin >> T; for (int i = 0; i < T; i++){ int N; cin >> N; string S; cin >> S; vector<int> Z = atcoder::z_algorithm(S); int ans = 0; for (int j = 1; j < N; j++){ int x = Z[j]; x = min({x, j, N - j}); if (x < j && x < N - j){ if (S[x] < S[j + x]){ ans++; } } else if (x < N - j){ ans++; } } cout << ans << endl; } }