結果
問題 | No.1707 Simple Range Reverse Problem |
ユーザー |
|
提出日時 | 2021-10-15 21:46:58 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 536 bytes |
コンパイル時間 | 1,365 ms |
コンパイル使用メモリ | 169,140 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-17 17:23:30 |
合計ジャッジ時間 | 2,230 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 18 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ int T; cin>>T; while(T--){ int N; cin>>N; vector<int>A(N*2),cnt(N); for(int &i:A)cin>>i; for(int i:A)cnt[i-1]++; int ans=0; for(int i:cnt){ if(i!=2){ ans=2; } } for(int i=0;i<N*2;i++){ if(A[i]!=i%N+1){ ans+=1; for(int j=0,t=(i%N==0?N:i%N)-1;j<N&&j+i<N*2;j++,t--){ if(t==0)t=N; if(A[i+j]!=t)ans=2; } i+=N; } } cout<<(ans<=1?"Yes\n":"No\n"); } }