結果

問題 No.360 増加門松列
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2016-04-17 23:13:06
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 970 bytes
コンパイル時間 1,051 ms
コンパイル使用メモリ 146,336 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 18:35:36
合計ジャッジ時間 1,969 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 3 ms
4,384 KB
testcase_08 AC 3 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 3 ms
4,384 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)

typedef vector<int> vi;

bool check(vi _a)
{
	vi a(3);
	rep(i, 0, 3) a[i] = _a[i];
	
	//rep(i, 0, 3) cout << a[i] << " ";
	//cout << endl;

	if (a[0] == a[1]) return false;
	if (a[0] == a[2]) return false;
	if (a[1] == a[2]) return false;
	if (a[2] < a[0]) return false;

	int _max = max(a[0], max(a[1], a[2]));
	int _min = min(a[0], min(a[1], a[2]));

	if (_max == a[1]) return true;
	if (_min == a[1]) return true;
	return false;
}

vi d(7);
int dfs(int depth)
{
	if (depth == 7)
	{
		bool ok = true;
		rep(i, 0, 5)
		{
			if (!check({ d[i], d[i + 1],d[i + 2] })) ok = false;
		}
		if (ok)
			return 1;
		else
			return 0;
	}

	int ret = 0;
	rep(i, depth, 7)
	{
		swap(d[depth], d[i]);
		ret += dfs(depth + 1);
		swap(d[depth], d[i]);
	}

	return ret;
}

int main()
{
	rep(i, 0, 7) cin >> d[i];

	int ans = dfs(0);
	if (ans)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
0