結果

問題 No.1331 Moving Penguin
ユーザー 👑 kmjpkmjp
提出日時 2021-01-08 22:47:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,275 bytes
コンパイル時間 1,872 ms
コンパイル使用メモリ 209,288 KB
実行使用メモリ 135,040 KB
最終ジャッジ日時 2024-04-28 04:15:56
合計ジャッジ時間 15,586 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
9,984 KB
testcase_01 AC 5 ms
9,056 KB
testcase_02 AC 5 ms
8,960 KB
testcase_03 AC 5 ms
8,892 KB
testcase_04 AC 46 ms
25,008 KB
testcase_05 AC 943 ms
107,520 KB
testcase_06 AC 926 ms
107,520 KB
testcase_07 AC 939 ms
107,520 KB
testcase_08 AC 40 ms
20,736 KB
testcase_09 AC 36 ms
20,736 KB
testcase_10 AC 36 ms
20,608 KB
testcase_11 AC 40 ms
20,732 KB
testcase_12 AC 40 ms
20,680 KB
testcase_13 AC 40 ms
20,548 KB
testcase_14 AC 76 ms
20,736 KB
testcase_15 AC 77 ms
20,648 KB
testcase_16 AC 79 ms
20,740 KB
testcase_17 AC 34 ms
20,736 KB
testcase_18 AC 31 ms
20,736 KB
testcase_19 AC 30 ms
20,632 KB
testcase_20 AC 31 ms
20,608 KB
testcase_21 AC 32 ms
20,784 KB
testcase_22 AC 32 ms
20,608 KB
testcase_23 AC 50 ms
20,716 KB
testcase_24 AC 49 ms
20,864 KB
testcase_25 AC 49 ms
20,608 KB
testcase_26 AC 101 ms
22,784 KB
testcase_27 AC 100 ms
22,728 KB
testcase_28 AC 108 ms
23,464 KB
testcase_29 AC 32 ms
20,608 KB
testcase_30 AC 29 ms
13,436 KB
testcase_31 AC 57 ms
16,748 KB
testcase_32 AC 25 ms
12,928 KB
testcase_33 AC 40 ms
14,976 KB
testcase_34 AC 61 ms
18,156 KB
testcase_35 TLE -
testcase_36 TLE -
testcase_37 TLE -
testcase_38 AC 29 ms
13,824 KB
testcase_39 AC 97 ms
22,144 KB
testcase_40 AC 51 ms
15,780 KB
testcase_41 TLE -
testcase_42 AC 182 ms
32,640 KB
testcase_43 AC 178 ms
32,640 KB
testcase_44 AC 184 ms
32,512 KB
testcase_45 AC 60 ms
20,864 KB
testcase_46 AC 56 ms
20,864 KB
testcase_47 AC 54 ms
20,864 KB
testcase_48 AC 29 ms
20,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N;
int A[101010];
unordered_map<int,ll> dp[101010];
ll S[101010];
const ll mo=1000000007;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	S[0]=1;
	for(i=1;i<=N;i++) {
		cin>>x;
		ll sum=0;
		FORR(m,dp[i]) sum+=m.second;
		sum+=S[i-1];
		S[i]=sum%mo;
		
		
		if(i==N) cout<<S[i]<<endl;
		
		if(x==1) (dp[i+2][1]+=S[i])%=mo;
		else (dp[i][x]+=S[i])%=mo;
		FORR(a,dp[i]) if(i+a.first<=N) {
			(dp[i+a.first][a.first]+=a.second)%=mo;
		}
		dp[i].clear();
		
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0