結果

問題 No.360 増加門松列
ユーザー kongarishisyamokongarishisyamo
提出日時 2016-04-25 09:15:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 491 ms / 2,000 ms
コード長 647 bytes
コンパイル時間 418 ms
コンパイル使用メモリ 59,928 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 18:38:14
合計ジャッジ時間 9,013 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<algorithm>

using namespace std;

bool jud(int a,int b,int c){
	return a<c&&a!=b&&b!=c&&a!=c&&(min(a,min(b,c))==b||max(a,max(b,c))==b);
}

int main(){

	int D[7];

	for(int i=0;i<7;i++) cin>>D[i];

	for(int i=123456;i<10000000;i++){
		int a[7];
		int b=i;
		for(int j=0;j<7;j++) a[6-j]=b%10,b/=10;
		bool f=true;
		for(int j=0;j<7;j++){
			if(a[j]<0||a[j]>6) f=false;
			for(int k=0;k<7;k++){
				if(j!=k&&a[k]==a[j]) f=false;
			}
		}
		if(f){
			f=true;
			for(int j=0;j<7-2;j++){
				if(!jud(D[a[j]],D[a[j+1]],D[a[j+2]])) f=false;
			}
			if(f){
				cout<<"YES"<<endl;

				return 0;
			}
		}
	}
	cout<<"NO"<<endl;
}
0