結果

問題 No.2454 Former < Latter
ユーザー binapbinap
提出日時 2023-09-01 23:09:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 264 ms / 2,000 ms
コード長 746 bytes
コンパイル時間 3,652 ms
コンパイル使用メモリ 227,480 KB
実行使用メモリ 6,244 KB
最終ジャッジ日時 2023-09-01 23:09:52
合計ジャッジ時間 5,407 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 12 ms
5,916 KB
testcase_03 AC 11 ms
6,080 KB
testcase_04 AC 12 ms
6,032 KB
testcase_05 AC 12 ms
6,088 KB
testcase_06 AC 12 ms
6,008 KB
testcase_07 AC 12 ms
5,936 KB
testcase_08 AC 12 ms
4,380 KB
testcase_09 AC 8 ms
4,376 KB
testcase_10 AC 10 ms
4,376 KB
testcase_11 AC 12 ms
6,088 KB
testcase_12 AC 11 ms
5,900 KB
testcase_13 AC 12 ms
6,244 KB
testcase_14 AC 11 ms
6,072 KB
testcase_15 AC 11 ms
4,792 KB
testcase_16 AC 11 ms
4,544 KB
testcase_17 AC 264 ms
4,376 KB
testcase_18 AC 16 ms
4,376 KB
testcase_19 AC 12 ms
6,208 KB
testcase_20 AC 14 ms
6,092 KB
testcase_21 AC 13 ms
4,376 KB
testcase_22 AC 9 ms
4,376 KB
testcase_23 AC 10 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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(z[p] == p){
				if(q == p){
				}else 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;
}
0