結果
問題 | No.360 増加門松列 |
ユーザー |
![]() |
提出日時 | 2016-07-21 09:08:53 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 609 bytes |
コンパイル時間 | 367 ms |
コンパイル使用メモリ | 54,812 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-24 04:34:55 |
合計ジャッジ時間 | 1,111 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:38:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 38 | scanf("%d",&ds[i]); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <iostream> #include <stdio.h> int ds[7]; int ts[7]; bool ans=false; bool f(int a,int b,int c){ if((a<b)&&(c<b)&&(a<c)){ return true; } if((a>b)&&(b<c)&&(a<c)){ return true; } return false; } void dfs(int deep){ if(deep==7){ bool ok=true; for(int i=0;i<5;i++){ ok=ok&&f(ts[i],ts[i+1],ts[i+2]); } ans=(ans||ok); }else{ for(int i=0;i<7;i++){ if(ts[i]!=-1)continue; ts[i]=ds[deep]; dfs(deep+1); ts[i]=-1; } } } int main() { // your code goes here for(int i=0;i<7;i++){ scanf("%d",&ds[i]); ts[i]=-1; } dfs(0); printf("%s\n",ans?"YES":"NO"); return 0; }