結果

問題 No.1707 Simple Range Reverse Problem
ユーザー chineristAC
提出日時 2021-09-17 21:18:32
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 2,022 bytes
コンパイル時間 22,237 ms
コンパイル使用メモリ 247,924 KB
最終ジャッジ日時 2025-01-24 14:31:11
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <random>
#include <stdio.h>
#include <fstream>
#include <functional>
#include <cassert>
//include "testlib.h"
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint1000000007;
#define rep(i,n,c) for (int i=0;i<n;i+=c)
#define append push_back
#define all(x) (x).begin(), (x).end()
template<class T>
using vec = vector<T>;
template<class T>
using vvec = vec<vec<T>>;
template<class T>
using vvvec = vec<vvec<T>>;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<class T>
bool chmin(T &a, T b){
if (a>b){
a = b;
return true;
}
return false;
}
template<class T>
bool chmax(T &a, T b){
if (a<b){
a = b;
return true;
}
return false;
}
template<class T>
T sum(vec<T> x){
T res=0;
for (auto e:x){
res += e;
}
return res;
}
template<class T>
void printv(vec<T> x,int s=20){
int cnt = 0;
for (auto e:x){
cnt += 1;
cout<<e<<" ";
if (cnt >= s){
break;
}
}
cout<<"\n";
}
bool solve(int n,vec<int> A){
bool no_ope = true;
for (int i=0;i<n;i++){
if (A[i]!=i+1 || A[i+n]!=i+1){
no_ope = false;
}
}
if (no_ope){
return true;
}
for (int i=0;i<n;i++){
vec<int> X(2*n);
for (int j=0;j<n;j++){
X[j] = j + 1;
X[j+n] = j + 1;
}
for (int j=i;j<=2*i+n-j;j++){
swap(X[j],X[2*i+n-j]);
}
if (X==A){
return true;
}
}
return false;
}
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int T;
cin>>T;
while (T--) {
int n;
cin>>n;
vec<int> A(2*n);
for (int i=0;i<2*n;i++){
cin>>A[i];
}
bool res = solve(n,A);
if (res){
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0