結果
| 問題 | No.2454 Former < Latter |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-26 10:46:38 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
TLE
不安定
|
| 実行時間 | - |
| コード長 | 691 bytes |
| 記録 | |
| コンパイル時間 | 411 ms |
| コンパイル使用メモリ | 95,724 KB |
| 実行使用メモリ | 86,528 KB |
| 最終ジャッジ日時 | 2026-08-26 10:46:46 |
| 合計ジャッジ時間 | 4,587 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 TLE * 1 -- * 21 |
ソースコード
T = int(input())
for _ in range(T):
N = int(input())
S = input().strip()
Z = [0]*N
Z[0] = N
l = 0
r = -1
for i in range(1,N):
if i>r:
k = 0
l = i
r = i-1
while i+k<N and S[k]==S[i+k]:
k += 1
r += 1
Z[i] = k
continue
Z[i] = min(Z[i-l],r-i+1)
k = 0
while i+Z[i]+k<N and S[i+Z[i]+k]==S[Z[i]+k]:
k += 1
Z[i] += k
ans = 0
for i in range(1,N):
if Z[i]<i and i+Z[i]<N and S[Z[i]]<S[i+Z[i]]:
ans += 1
continue
if Z[i]>=i and i+i<N:
ans += 1
print(ans)