結果

問題 No.1707 Simple Range Reverse Problem
ユーザー forest3
提出日時 2021-11-17 17:01:29
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 1,466 ms
コンパイル使用メモリ 172,284 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-23 17:53:00
合計ジャッジ時間 2,341 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
	int T;
	cin >> T;

	for( int i = 0; i < T; i ++ ) {
		int N;
		cin >> N;
		vector<int> X( 2 * N );
		for( int j = 0; j < N; j++ ) X[j] = j + 1;
		for( int j = 0; j < N; j++ ) X[j + N] = j + 1;
		vector<int> A( 2 * N );
		for( int j = 0; j < 2 * N; j++ ) cin >> A[j];
		string ans = "No";
		if( A == X ) ans = "Yes";
		else {
			for( int j = 0; j < N; j++ ) {
				vector<int> x = X;
				reverse( x.begin() + j, x.begin() + j + N + 1 );
				if( A == x ) {
					ans = "Yes";
					break;
				}
			}
		}
		cout << ans << endl;
	}
}
0