結果
| 問題 | No.334 門松ゲーム |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-01-17 15:11:11 |
| 言語 | C++11(old_compat) (gcc 12.4.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 13 ms / 2,000 ms |
| コード長 | 1,505 bytes |
| 記録 | |
| コンパイル時間 | 1,281 ms |
| コンパイル使用メモリ | 170,760 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2026-03-08 16:05:14 |
| 合計ジャッジ時間 | 1,715 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:37:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
37 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:39:35: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
39 | for(auto&& i : range(n)) { scanf("%d", &K[i]); }
| ~~~~~^~~~~~~~~~~~~
ソースコード
#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;
}