結果

問題 No.1859 ><<<
ユーザー 👑 NachiaNachia
提出日時 2022-02-26 20:05:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 895 bytes
コンパイル時間 1,502 ms
コンパイル使用メモリ 98,408 KB
実行使用メモリ 15,264 KB
最終ジャッジ日時 2023-09-17 23:10:08
合計ジャッジ時間 5,400 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 43 ms
15,240 KB
testcase_05 AC 43 ms
15,184 KB
testcase_06 AC 42 ms
15,116 KB
testcase_07 AC 43 ms
15,248 KB
testcase_08 AC 42 ms
15,264 KB
testcase_09 AC 43 ms
15,184 KB
testcase_10 AC 9 ms
5,084 KB
testcase_11 AC 30 ms
9,972 KB
testcase_12 AC 26 ms
9,120 KB
testcase_13 AC 16 ms
6,652 KB
testcase_14 AC 31 ms
10,560 KB
testcase_15 AC 41 ms
13,436 KB
testcase_16 AC 44 ms
14,428 KB
testcase_17 AC 34 ms
11,200 KB
testcase_18 AC 44 ms
14,112 KB
testcase_19 AC 33 ms
10,900 KB
testcase_20 AC 38 ms
13,484 KB
testcase_21 AC 41 ms
14,940 KB
testcase_22 AC 41 ms
14,380 KB
testcase_23 AC 36 ms
13,448 KB
testcase_24 AC 41 ms
14,584 KB
testcase_25 AC 44 ms
14,348 KB
testcase_26 AC 42 ms
13,736 KB
testcase_27 AC 45 ms
14,324 KB
testcase_28 AC 43 ms
14,048 KB
testcase_29 AC 44 ms
13,828 KB
testcase_30 AC 41 ms
13,464 KB
testcase_31 AC 41 ms
13,396 KB
testcase_32 AC 46 ms
14,672 KB
testcase_33 AC 42 ms
13,424 KB
testcase_34 AC 44 ms
14,076 KB
testcase_35 AC 48 ms
14,888 KB
testcase_36 AC 47 ms
14,964 KB
testcase_37 AC 43 ms
13,528 KB
testcase_38 AC 48 ms
15,136 KB
testcase_39 AC 47 ms
14,900 KB
testcase_40 AC 40 ms
14,676 KB
testcase_41 AC 42 ms
14,976 KB
testcase_42 AC 36 ms
13,168 KB
testcase_43 AC 40 ms
14,352 KB
testcase_44 AC 40 ms
14,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <atcoder/string>
#include <atcoder/modint>
using namespace std;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
using modint = atcoder::static_modint<998244353>;




int main(){
    int N; cin >> N;
    vector<int> A(N); rep(i,N) cin >> A[i];
    string S; cin >> S;

    rep(i,N-1) A.push_back(A[i]);
    string G;
    rep(i,A.size()-1){
        if(A[i] < A[i+1]) G.push_back('<');
        else G.push_back('>');
    }

    auto Q = atcoder::z_algorithm(S+G);
    vector<int> goals;
    rep(i,N) if(Q[N-1+i] >= N-1) goals.push_back(i);

    if(goals.empty()){ cout << "-1\n"; return 0; }

    cout << goals[0] << endl;

    return 0;
}




struct ios_do_not_sync{
    ios_do_not_sync(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
    }
} ios_do_not_sync_instance;
0