結果

問題 No.334 門松ゲーム
ユーザー hogeover30hogeover30
提出日時 2016-01-25 15:57:51
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 876 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 53,008 KB
最終ジャッジ日時 2024-04-27 02:17:04
合計ジャッジ時間 683 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、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])) {
      |                         ^

ソースコード

diff #

#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;
}

0