結果
問題 | No.2454 Former < Latter |
ユーザー |
|
提出日時 | 2023-09-01 22:13:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 255 ms / 2,000 ms |
コード長 | 407 bytes |
コンパイル時間 | 4,056 ms |
コンパイル使用メモリ | 251,444 KB |
最終ジャッジ日時 | 2025-02-16 16:44:22 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; int main () { int T; cin >> T; while (T--) { int N; cin >> N; string s; cin >> s; auto v = z_algorithm(s); int ans = 0; for (int i = 1; i < N; i ++) { int l = v[i]; if (l < min(i, N - i)) { ans += s[l] < s[i + l]; } else { ans += i < (N - i); } } cout << ans << endl; } }