結果
| 問題 |
No.334 門松ゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-01-17 15:11:11 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,505 bytes |
| コンパイル時間 | 344 ms |
| コンパイル使用メモリ | 51,760 KB |
| 最終ジャッジ日時 | 2024-11-14 19:32:29 |
| 合計ジャッジ時間 | 671 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:17:1: error: ‘vector’ does not name a type
17 | vector<int> K;
| ^~~~~~
main.cpp: In function ‘bool nya(bool)’:
main.cpp:24:17: error: ‘K’ was not declared in this scope
24 | int x = K[a], y = K[b], z = K[c];
| ^
main.cpp:25:17: error: ‘y’ was not declared in this scope
25 | if(!(x&&y&&z)) { continue; }
| ^
main.cpp:25:20: error: ‘z’ was not declared in this scope
25 | if(!(x&&y&&z)) { continue; }
| ^
main.cpp:26:24: error: ‘y’ was not declared in this scope
26 | if(!is_kado(x, y, z)) { continue; }
| ^
main.cpp:26:27: error: ‘z’ was not declared in this scope
26 | if(!is_kado(x, y, z)) { continue; }
| ^
main.cpp:29:26: error: ‘y’ was not declared in this scope
29 | K[a] = x, K[b] = y, K[c] = z;
| ^
main.cpp:29:36: error: ‘z’ was not declared in this scope
29 | K[a] = x, K[b] = y, K[c] = z;
| ^
main.cpp: In function ‘int main()’:
main.cpp:38:3: error: ‘K’ was not declared in this scope
38 | K.assign(n, 0);
| ^
main.cpp:45:17: error: ‘y’ was not declared in this scope
45 | if(!(x&&y&&z)) { continue; }
| ^
main.cpp:45:20: error: ‘z’ was not declared in this scope
45 | if(!(x&&y&&z)) { continue; }
| ^
main.cpp:46:24: error: ‘y’ was not declared in this scope
46 | if(!is_kado(x, y, z)) { continue; }
| ^
main.cpp:46:27: error: ‘z’ was not declared in this scope
46 | if(!is_kado(x, y, z)) { continue; }
| ^
main.cpp:52:26: error: ‘y’ was not declared in this scope
52 | K[a] = x, K[b] = y, K[c] = z;
| ^
main.cpp:52:36
ソースコード
#include <iostream>
#include <algorithm>
#include <cassert>
using namespace std;
using i64 = long long;
template<typename T>
class Range{private:struct I{T x;T operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:Range(T n):i({0}),n({n}){}Range(T i,T n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};
using range = Range<i64>;
bool is_kado(int a, int b, int c) {
return (a!=b&&b!=c&&c!=a) && ((a>b&&b<c) || (a<b&&b>c));
}
int n;
vector<int> K;
bool nya(bool is_bob) {
bool res = false;
for(auto&& a : range(n)) {
for(auto&& b : range(a+1, n)) {
for(auto&& c : range(b+1, n)) {
int x = K[a], y = K[b], z = K[c];
if(!(x&&y&&z)) { continue; }
if(!is_kado(x, y, z)) { continue; }
K[a] = 0, K[b] = 0, K[c] = 0;
res |= !nya(!is_bob);
K[a] = x, K[b] = y, K[c] = z;
}
}
}
return res;
}
int main(void) {
scanf("%d", &n);
K.assign(n, 0);
for(auto&& i : range(n)) { scanf("%d", &K[i]); }
// puts(nya(0) ? "Yes" : "-1");
for(auto&& a : range(n)) {
for(auto&& b : range(a+1, n)) {
for(auto&& c : range(b+1, n)) {
int x = K[a], y = K[b], z = K[c];
if(!(x&&y&&z)) { continue; }
if(!is_kado(x, y, z)) { continue; }
K[a] = 0, K[b] = 0, K[c] = 0;
if(!nya(1)) {
printf("%lld %lld %lld\n", a, b, c);
return 0;
}
K[a] = x, K[b] = y, K[c] = z;
}
}
}
puts("-1");
return 0;
}