結果
| 問題 |
No.334 門松ゲーム
|
| コンテスト | |
| ユーザー |
nmnmnmnmnmnmnm
|
| 提出日時 | 2016-01-16 20:39:26 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 17 ms / 2,000 ms |
| コード長 | 1,634 bytes |
| コンパイル時間 | 895 ms |
| コンパイル使用メモリ | 95,460 KB |
| 実行使用メモリ | 7,552 KB |
| 最終ジャッジ日時 | 2024-09-19 20:15:11 |
| 合計ジャッジ時間 | 1,391 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define MOD 1000000007
int n;
vector<int> v;
int grundy[1<<20];
int isKadomatsu(int a, int b, int c){
if((a<b&&a>c)||(a>b&&a<c)||(c<a&&c>b)||(c>a&&c<b))return 1;
return 0;
}
int f(int d){
set<int> se;
rep(a,0,n){
rep(b,a+1,n){
rep(c,b+1,n){
if((d&(1<<a))!=0||(d&(1<<b))!=0||(d&(1<<c))!=0)continue;
if(isKadomatsu(v[a],v[b],v[c])==1){
int d1 = d;
d1 |= 1<<a;
d1 |= 1<<b;
d1 |= 1<<c;
se.insert(f(d1));
}
}
}
}
int g = 0;
while(se.count(g)!=0)g++;
return g;
}
int main(){
cin>>n;
rep(i,0,n){
int a;
cin>>a;
v.pb(a);
}
clr(grundy,-1);
rep(a,0,n){
rep(b,a+1,n){
rep(c,b+1,n){
if(1==isKadomatsu(v[a],v[b],v[c])){
int d = 0;
d |= 1<<a;
d |= 1<<b;
d |= 1<<c;
if(0==f(d)){
cout << a << " " << b << " " << c << endl;
return 0;
}
}
}
}
}
cout << -1 << endl;
return 0;
}
// grundy数解
nmnmnmnmnmnmnm