結果

問題 No.533 Mysterious Stairs
ユーザー HERROHERRO
提出日時 2017-06-24 00:09:48
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,035 bytes
コンパイル時間 616 ms
コンパイル使用メモリ 71,256 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-15 01:13:07
合計ジャッジ時間 11,185 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 9 ms
5,376 KB
testcase_12 AC 23 ms
5,376 KB
testcase_13 AC 63 ms
5,376 KB
testcase_14 AC 73 ms
5,376 KB
testcase_15 AC 191 ms
5,376 KB
testcase_16 AC 794 ms
5,376 KB
testcase_17 AC 2,692 ms
5,376 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<map>

using namespace std;

typedef map<int,int> imap;

int main() {
 int n;
 cin >> n;
 if(n<3){ cout << 1 << endl; return 0; }
 if(n==3){ cout << 3 << endl; return 0; }
 imap a, b, c;
 int ans=0,m=int(1e9)+7;
 a[1]=1;b[2]=1;c[3]=1;
 while(a.size()>0||b.size()>0||c.size()>0){
  imap x, y, z;
  for(auto it=a.begin();it!=a.end();it++){
   int k=it->first,v=it->second;
   if(k+2<n){y[k+2]=(y[k+2]+v)%m;}
   else if(k+2==n){ans=(ans+v)%m;}
   if(k+3<n){z[k+3]=(z[k+3]+v)%m;}
   else if(k+3==n){ans=(ans+v)%m;}
  }
  for(auto it=b.begin();it!=b.end();it++){
   int k=it->first,v=it->second;
   if(k+1<n){x[k+1]=(x[k+1]+v)%m;}
   else if(k+1==n){ans=(ans+v)%m;}
   if(k+3<n){z[k+3]=(z[k+3]+v)%m;}
   else if(k+3==n){ans=(ans+v)%m;}
  }
  for(auto it=c.begin();it!=c.end();it++){
   int k=it->first,v=it->second;
   if(k+1<n){x[k+1]=(x[k+1]+v)%m;}
   else if(k+1==n){ans=(ans+v)%m;}
   if(k+2<n){y[k+2]=(y[k+2]+v)%m;}
   else if(k+2==n){ans=(ans+v)%m;}
  }
  a=x;b=y;c=z;
 }
 cout << ans << endl;
 return 0;
}
0