結果
| 問題 |
No.334 門松ゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-11-26 10:06:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,139 bytes |
| コンパイル時間 | 1,786 ms |
| コンパイル使用メモリ | 175,700 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-27 11:24:40 |
| 合計ジャッジ時間 | 2,259 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 WA * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int kado( int x, int y, int z ){
if( x == y or y == z or z == x )
return 0;
if( not ( min( { x, y, z } ) == y or max( { x, y, z } ) == y ) )
return 0;
return 1;
}
tuple< int, int, int > dfs( const vector< int > &a ){
if( a.empty() )
return make_tuple( -1, -1, -1 );
for( int i = 0; i < a.size(); ++i )
for( int j = i + 1; j < a.size(); ++j )
for( int k = j + 1; k < a.size(); ++k )
if( kado( a[ i ], a[ j ], a[ k ] ) ){
vector< int > t = a;
t.erase( find( t.begin(), t.end(), a[ i ] ) );
t.erase( find( t.begin(), t.end(), a[ j ] ) );
t.erase( find( t.begin(), t.end(), a[ k ] ) );
tuple< int, int, int > u = dfs( t );
if( get< 0 >( u ) == -1 )
return make_tuple( i, j, k );
}
return make_tuple( -1, -1, -1 );
}
signed main(){
int N; cin >> N;
vector< int > A( N );
for( int i = 0; i < N; ++i )
cin >> A[ i ];
int a, b, c; tie( a, b, c ) = dfs( A );
if( a == -1 )
cout << a << endl;
else
cout << a << " " << b << " " << c << endl;
return 0;
}