結果
問題 | No.314 ケンケンパ |
ユーザー |
|
提出日時 | 2015-12-07 00:23:42 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 866 ms / 1,000 ms |
コード長 | 1,043 bytes |
コンパイル時間 | 558 ms |
コンパイル使用メモリ | 50,176 KB |
実行使用メモリ | 303,712 KB |
最終ジャッジ日時 | 2024-09-14 17:05:21 |
合計ジャッジ時間 | 4,459 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:44:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 44 | scanf("%d",&n); | ~~~~~^~~~~~~~~
ソースコード
#include <unordered_map>#include <cstdio>using namespace std;namespace std{template<typename T>inline void hash_combine(size_t& seed, T const& v){seed ^= hash<T>()(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);}template<typename It>inline size_t hash_range(It first, It last){size_t seed=0;hash_range(seed,first,last);return seed;}template<typename It>inline void hash_range(size_t& seed, It first, It last){for(;first!=last;++first)hash_combine(seed, *first);}template<typename A,typename B>class hash<pair<A,B>>{public:size_t operator()(pair<A,B> const &p) const{size_t seed=0;hash_combine(seed,p.first);hash_combine(seed,p.second);return seed;}};}unordered_map<pair<pair<int,int>,int>,int>memo;int dfs(int k,int p,int d){if(k<0||p<0)return 0;if(d==0)return 1;auto x=make_pair(make_pair(k,p),d);if(memo.find(x)==memo.end()){memo[x]=(dfs(k-1,1,d-1)+dfs(2,p-1,d-1))%1000000007;}return memo[x];}int main(){int n;scanf("%d",&n);printf("%d\n",dfs(2,0,n));}