結果
問題 | No.361 門松ゲーム2 |
ユーザー | dnish |
提出日時 | 2017-03-02 12:10:35 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 435 ms / 2,000 ms |
コード長 | 659 bytes |
コンパイル時間 | 1,588 ms |
コンパイル使用メモリ | 169,876 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-03 20:27:59 |
合計ジャッジ時間 | 3,704 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 1 ms
4,376 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 2 ms
4,380 KB |
testcase_11 | AC | 2 ms
4,380 KB |
testcase_12 | AC | 2 ms
4,380 KB |
testcase_13 | AC | 1 ms
4,380 KB |
testcase_14 | AC | 147 ms
4,376 KB |
testcase_15 | AC | 3 ms
4,376 KB |
testcase_16 | AC | 42 ms
4,376 KB |
testcase_17 | AC | 13 ms
4,380 KB |
testcase_18 | AC | 9 ms
4,380 KB |
testcase_19 | AC | 8 ms
4,380 KB |
testcase_20 | AC | 3 ms
4,376 KB |
testcase_21 | AC | 45 ms
4,380 KB |
testcase_22 | AC | 435 ms
4,380 KB |
testcase_23 | AC | 2 ms
4,376 KB |
testcase_24 | AC | 3 ms
4,376 KB |
testcase_25 | AC | 4 ms
4,376 KB |
testcase_26 | AC | 15 ms
4,376 KB |
testcase_27 | AC | 21 ms
4,380 KB |
ソースコード
#include <bits/stdc++.h> #define REP(i,n,N) for(int i=n;i<N;i++) #define p(S) cout<<(S)<<endl #define ck(a,b) (0<=(a)&&(a)<b) typedef long long ll; using namespace std; int mem[501]; int L,D; int grundy(int n){ if(mem[n]!=-1) return mem[n]; set<int> s; REP(i,1,n){ REP(j,i+1,n){ int k=n-i-j; if(k<1) continue; if(i==k||j==k) continue; int mx=max(j,k); int mn=min(i,k); if(mx-mn>D) continue; s.insert(grundy(i)^grundy(j)^grundy(k)); } } int ret=0; while(s.find(ret)!=s.end()){ ret++; } return mem[n]=ret; } int main(){ cin>>L>>D; memset(mem,-1,sizeof(mem)); int g=grundy(L); p((g!=0)?"kado":"matsu"); return 0; }