結果
| 問題 |
No.334 門松ゲーム
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2016-01-25 15:57:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 876 bytes |
| コンパイル時間 | 655 ms |
| コンパイル使用メモリ | 51,752 KB |
| 最終ジャッジ日時 | 2024-11-14 19:32:33 |
| 合計ジャッジ時間 | 1,036 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:10:16: error: ‘vector’ does not name a type
10 | bool win(const vector<int>& a, int mask)
| ^~~~~~
main.cpp:10:22: error: expected ‘,’ or ‘...’ before ‘<’ token
10 | bool win(const vector<int>& a, int mask)
| ^
main.cpp: In function ‘bool win(int)’:
main.cpp:12:11: error: ‘a’ was not declared in this scope
12 | int n=a.size();
| ^
main.cpp:16:15: error: ‘mask’ was not declared in this scope
16 | int m=mask&~((1<<i)|(1<<j)|(1<<k));
| ^~~~
main.cpp: In function ‘int main()’:
main.cpp:26:5: error: ‘vector’ was not declared in this scope
26 | vector<int> a(n); for(int& v: a) cin>>v;
| ^~~~~~
main.cpp:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
2 | #include <algorithm>
+++ |+#include <vector>
3 | using namespace std;
main.cpp:26:12: error: expected primary-expression before ‘int’
26 | vector<int> a(n); for(int& v: a) cin>>v;
| ^~~
main.cpp:26:35: error: ‘a’ was not declared in this scope
26 | vector<int> a(n); for(int& v: a) cin>>v;
| ^
main.cpp:28:25: error: ‘a’ was not declared in this scope
28 | if (isKadomatsu(a[i], a[j], a[k])) {
| ^
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
bool isKadomatsu(int a, int b, int c)
{
return b>a and b>c or b<a and b<c;
}
bool win(const vector<int>& a, int mask)
{
int n=a.size();
bool res=true;
#define REP(i, a, b) for(int i=a;i<b;++i)
REP(i, 0, n) REP(j, i+1, n) REP(k, j+1, n) {
int m=mask&~((1<<i)|(1<<j)|(1<<k));
if ((mask&(1<<i)) and (mask&(1<<j)) and (mask&(1<<k)) and isKadomatsu(a[i], a[j], a[k]))
res=res and !win(a, m);
}
return res;
}
int main()
{
int n; cin>>n;
vector<int> a(n); for(int& v: a) cin>>v;
REP(i, 0, n) REP(j, i+1, n) REP(k, j+1, n) {
if (isKadomatsu(a[i], a[j], a[k])) {
if (win(a, ((1<<n)-1)^(1<<i)^(1<<j)^(1<<k))) {
cout<<i<<' '<<j<<' '<<k<<endl;
return 0;
}
}
}
cout<<-1<<endl;
}
hogeover30