結果
問題 |
No.1859 ><<<
|
ユーザー |
👑 ![]() |
提出日時 | 2022-02-26 20:05:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 77 ms / 2,000 ms |
コード長 | 895 bytes |
コンパイル時間 | 1,648 ms |
コンパイル使用メモリ | 97,576 KB |
最終ジャッジ日時 | 2025-01-28 03:32:18 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 41 |
ソースコード
#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;