結果

問題 No.2454 Former < Latter
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-09-01 22:13:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 254 ms / 2,000 ms
コード長 407 bytes
コンパイル時間 4,613 ms
コンパイル使用メモリ 260,000 KB
実行使用メモリ 6,208 KB
最終ジャッジ日時 2023-09-01 22:13:47
合計ジャッジ時間 6,462 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 11 ms
6,016 KB
testcase_03 AC 11 ms
5,984 KB
testcase_04 AC 12 ms
5,936 KB
testcase_05 AC 12 ms
6,020 KB
testcase_06 AC 12 ms
6,200 KB
testcase_07 AC 12 ms
5,940 KB
testcase_08 AC 11 ms
4,380 KB
testcase_09 AC 8 ms
4,376 KB
testcase_10 AC 9 ms
4,376 KB
testcase_11 AC 11 ms
5,940 KB
testcase_12 AC 11 ms
5,972 KB
testcase_13 AC 11 ms
5,988 KB
testcase_14 AC 12 ms
6,040 KB
testcase_15 AC 11 ms
4,780 KB
testcase_16 AC 10 ms
4,528 KB
testcase_17 AC 254 ms
4,376 KB
testcase_18 AC 15 ms
4,380 KB
testcase_19 AC 11 ms
6,208 KB
testcase_20 AC 13 ms
5,996 KB
testcase_21 AC 12 ms
4,376 KB
testcase_22 AC 8 ms
4,380 KB
testcase_23 AC 9 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
	}
}
0