結果

問題 No.361 門松ゲーム2
ユーザー cormorancormoran
提出日時 2016-09-13 22:26:49
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,452 bytes
コンパイル時間 1,440 ms
コンパイル使用メモリ 168,844 KB
実行使用メモリ 10,144 KB
最終ジャッジ日時 2024-04-28 13:15:14
合計ジャッジ時間 5,082 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,012 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 4 ms
6,944 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 24 ms
6,944 KB
testcase_12 AC 60 ms
6,940 KB
testcase_13 AC 57 ms
6,944 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    int L, D;
    bool solve() {
        cin >> L >> D;

        if(D == 1) {
            cout << "matsu" << endl;
        }
        
        vector<int> grundy(L + 1);
        rep(l, grundy.size()) {
            
            if(l < 6) {
                grundy[l] = 0;
            } else if(D == 2 and (l - 6) % 3 != 0) {
                grundy[l] = 0;
            } else {
                set<int> reachable;
                cerr << "@@@@@@@@ " << l << " @@@@@@" << endl;
                repeat(L1, 1, l + 1) {
                    repeat(L2, L1 + 1, l - L1 + 1) {    
                        int L3 = l - L1 - L2;
                        if(L3 <= L2 or L3 - L1 > D) break;
                        cerr << "!" << endl;
                        cerr << L1 << " " << L2 << " " << L3 << endl;
                        cerr << grundy[L1] << " " << grundy[L2] << " " << grundy[L3] << endl;
                        cerr << (grundy[L1] ^ grundy[L2] ^ grundy[L3]) << endl;
                        reachable.insert(grundy[L1] ^ grundy[L2] ^ grundy[L3]);
                    }
                }
                int mex = 0;
                for(int g : reachable) {
                    if(mex == g) mex++;
                }
                grundy[l] = mex;
            }
        }
        debug(grundy);
        cout << (grundy.back() != 0 ? "kado" : "matsu") << endl;
        
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}
0