結果

問題 No.334 門松ゲーム
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2016-01-16 20:39:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 1,634 bytes
コンパイル時間 780 ms
コンパイル使用メモリ 96,500 KB
実行使用メモリ 7,788 KB
最終ジャッジ日時 2023-10-20 00:22:31
合計ジャッジ時間 1,718 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,784 KB
testcase_01 AC 3 ms
7,780 KB
testcase_02 AC 18 ms
7,784 KB
testcase_03 AC 4 ms
7,784 KB
testcase_04 AC 3 ms
7,784 KB
testcase_05 AC 3 ms
7,784 KB
testcase_06 AC 5 ms
7,784 KB
testcase_07 AC 9 ms
7,780 KB
testcase_08 AC 5 ms
7,784 KB
testcase_09 AC 6 ms
7,784 KB
testcase_10 AC 16 ms
7,784 KB
testcase_11 AC 8 ms
7,784 KB
testcase_12 AC 4 ms
7,788 KB
testcase_13 AC 4 ms
7,788 KB
testcase_14 AC 20 ms
7,780 KB
testcase_15 AC 9 ms
7,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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数解
0