結果

問題 No.1707 Simple Range Reverse Problem
ユーザー pengin_2000
提出日時 2022-11-23 13:32:40
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 569 bytes
コンパイル時間 470 ms
コンパイル使用メモリ 29,696 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-24 18:08:01
合計ジャッジ時間 1,284 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
int n;
int a[1003];
void solve()
{
	int i;
	if (a[0] != 1 || a[2 * n - 1] != n)
	{
		printf("No\n");
		return;
	}
	for (i = 0; i < 2 * n - 1; i++)
	{
		if (a[i] - a[i + 1] == 1)
			continue;
		if (a[i] - a[i + 1] == -1)
			continue;
		if (a[i] - a[i + 1] == n - 1)
			continue;
		if (a[i] - a[i + 1] == 1 - n)
			continue;
		printf("No\n");
		return;
	}
	printf("Yes\n");
	return;
}
int main()
{
	int t;
	scanf("%d", &t);
	int i;
	for (; t > 0; t--)
	{
		scanf("%d", &n);
		for (i = 0; i < 2 * n; i++)
			scanf("%d", &a[i]);
		solve();
	}
	return 0;
}
0