結果
問題 |
No.2454 Former < Latter
|
ユーザー |
👑 |
提出日時 | 2023-09-01 23:05:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 678 bytes |
コンパイル時間 | 3,707 ms |
コンパイル使用メモリ | 219,904 KB |
実行使用メモリ | 6,080 KB |
最終ジャッジ日時 | 2025-01-03 11:08:28 |
合計ジャッジ時間 | 4,995 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 16 WA * 7 |
ソースコード
#include<bits/stdc++.h> #include<atcoder/all> #define rep(i,n) for(int i=0;i<n;i++) using namespace std; using namespace atcoder; typedef long long ll; typedef vector<int> vi; typedef vector<long long> vl; typedef vector<vector<int>> vvi; typedef vector<vector<long long>> vvl; typedef pair<int,int> P; typedef long double ld; void solve(){ int n; cin >> n; string s; cin >> s; vi z = z_algorithm(s); int ans = 0; rep(p, n){ if(p == 0) continue; int q = n - p; if(z[p] >= p){ ans++; }else{ if(p + z[p] == n){ }else{ if(s[z[p]] < s[p + z[p]]) ans++; } } } cout << ans << "\n"; } int main(){ int t; cin >> t; rep(i, t) solve(); return 0; }