結果
| 問題 |
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,347 ms |
| コンパイル使用メモリ | 162,664 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-07-13 03:51:09 |
| 合計ジャッジ時間 | 2,066 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 19 |
ソースコード
#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");
}
}