제출 #994582

#제출 시각아이디문제언어결과실행 시간메모리
994582PenguinsAreCuteTrains (BOI24_trains)C++17
16 / 100
192 ms124068 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int SQ = 313; const int MOD = 1e9 + 7; main() { int n; cin >> n; int d[n], x[n]; for(int i=0;i<n;i++) cin>>d[i]>>x[i]; int dp[n], pre[n][SQ]; for(int i=n;i--;) { dp[i]=1; if(d[i]>=SQ) for(int j=1;j<=x[i]&&i+j*d[i]<n;j++) {dp[i]+=dp[i+j*d[i]]; if(dp[i]>=MOD) dp[i]-=MOD;} else if(d[i]) { if(i+d[i]<n) dp[i]+=pre[i+d[i]][d[i]]; if(i+d[i]*(x[i]+1)<n) dp[i]-=pre[i+d[i]*(x[i]+1)][d[i]]; if(dp[i]>=MOD) dp[i]-=MOD; if(dp[i]<0) dp[i]+=MOD; } for(int j=1;j<SQ;j++) {pre[i][j]=dp[i]+(i+j<n?pre[i+j][j]:0); if(pre[i][j]>=MOD) pre[i][j]-=MOD;} } cout << dp[0]; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...