結果
| 問題 |
No.361 門松ゲーム2
|
| コンテスト | |
| ユーザー |
cormoran
|
| 提出日時 | 2016-09-13 22:32:16 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,117 bytes |
| コンパイル時間 | 1,683 ms |
| コンパイル使用メモリ | 174,684 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 05:06:52 |
| 合計ジャッジ時間 | 2,999 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 WA * 13 |
ソースコード
#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;
vector<int> grundy;
int calc_grundy(int l) {
if(grundy[l] >= 0) return grundy[l];
if(l < 6) {
return grundy[l] = 0;
} else if(D == 2 and (l - 6) % 3 != 0) {
return grundy[l] = 0;
} else {
set<int> reachable;
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;
reachable.insert(calc_grundy(L1) ^ calc_grundy(L2) ^ calc_grundy(L3));
}
}
int mex = 0;
for(int g : reachable) {
if(mex == g) mex++;
}
return grundy[l] = mex;
}
}
bool solve() {
cin >> L >> D;
if(D == 1) {
cout << "matsu" << endl;
}
grundy.resize(L + 1, -1);
cout << (calc_grundy(L) != 0 ? "kado" : "matsu") << endl;
return 0;
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
Solver s;
s.solve();
return 0;
}
cormoran