結果

問題 No.1859 ><<<
ユーザー Nzt3Nzt3
提出日時 2022-03-16 00:06:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,124 bytes
コンパイル時間 1,855 ms
コンパイル使用メモリ 171,232 KB
実行使用メモリ 7,260 KB
最終ジャッジ日時 2023-10-23 23:28:09
合計ジャッジ時間 11,592 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 49 ms
5,632 KB
testcase_12 AC 39 ms
5,284 KB
testcase_13 WA -
testcase_14 AC 40 ms
5,688 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 46 ms
6,024 KB
testcase_18 WA -
testcase_19 AC 48 ms
5,992 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 74 ms
6,932 KB
testcase_26 WA -
testcase_27 AC 77 ms
6,904 KB
testcase_28 AC 61 ms
6,884 KB
testcase_29 AC 71 ms
6,824 KB
testcase_30 AC 66 ms
6,496 KB
testcase_31 WA -
testcase_32 AC 76 ms
6,988 KB
testcase_33 WA -
testcase_34 AC 58 ms
6,836 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 71 ms
6,612 KB
testcase_38 AC 83 ms
7,260 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 63 ms
6,592 KB
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

long long modpow(long long a,int n,long long mod){
  long long ret=1,t=a;
  for(int i=0;i<31;i++){
    if(n>>i&1)ret=ret*t%mod;
    t=t*t%mod;
  }
  return ret;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin>>N;
  vector<int>A(N);
  for(int &i:A)cin>>i;
  string S;
  cin>>S;
  vector<int>F(N*2);
  for(int i=0;i<N*2;i++){
    F[i]=A[i%N]>A[(i+1)%N];
  }

  const int mod[4]={1000000007,1000000009,998244853,998244353};
  array<long long,4>inori={0ll,0ll,0ll,0ll},awase=inori,modkese;
  for(int i=0;i<4;i++)modkese[i]=modpow(2,N-1,mod[i]);
  for(int i=0;i<N-1;i++){
    for(int j=0;j<4;j++){
      inori[j]=(inori[j]*2+(S[i]=='>'?1:0))%mod[j];
    }
  }
  for(int i=0;i<N-2;i++){
    for(int j=0;j<4;j++){
      awase[j]=(awase[j]*2+F[i])%mod[j];
    }
  }
  for(int i=N-2;i<N*2;i++){
    for(int j=0;j<4;j++){
      awase[j]=(awase[j]*2+F[i])%mod[j];
    }
    if(inori==awase){
      cout<<i-N+2<<'\n';
      return 0;
    }
    for(int j=0;j<4;j++){
      if(F[i-N+1])awase[j]=(awase[j]-modkese[j]+mod[j])%mod[j];
    }
  }
  cout<<"-1\n";
}
0