結果
| 問題 |
No.2454 Former < Latter
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-09-01 21:42:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 42 ms / 2,000 ms |
| コード長 | 436 bytes |
| コンパイル時間 | 1,739 ms |
| コンパイル使用メモリ | 88,236 KB |
| 実行使用メモリ | 5,984 KB |
| 最終ジャッジ日時 | 2025-01-03 07:56:39 |
| 合計ジャッジ時間 | 2,434 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 23 |
ソースコード
#include<iostream>
#include<cassert>
#include<atcoder/string>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;cin>>T;
for(;T--;)
{
int N;string S;
cin>>N>>S;
vector<int>Z=atcoder::z_algorithm(S);
int ans=0;
for(int i=1;i<N;i++)
{
int len=Z[i];
if(i+len>=N)
{
if(i<N-i)ans++;
}
else if(len>=i)ans++;
else if(S[len]<S[i+len])ans++;
}
cout<<ans<<"\n";
}
}