#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const ll mod = 1000007;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie();
cout.tie();
int n;
cin>>n;
vector<ll> dp(n+1,0);
vector<ll> dp2(n+1,0);
dp[1]=2;
ll broj=2;
vector<ll> v;
ll brojac=0;
for(int i=0;i<n;i++)
{
ll a;
cin>>a;
v.push_back(a);
}
dp[1]=2;
dp2[1]=2;
for(int i=2;i<=n;i++)
{
broj++;
broj%=mod;
dp[i]=broj;
dp[i]%=mod;
dp2[i]=dp2[i-1]+broj;
dp2[i]%=mod;
}
for(int i=n-1;i>=1;i--)
{
for(int j=1;j<=n;j++)
cout<<dp2[j]<<" ";
cout<<endl;
brojac+=dp2[v[i-1]-1];
brojac%=mod;
dp[1]=dp2[1]+dp2[2];
dp[1]%=mod;
dp2[1]=dp[1];
broj=dp[1];
for(int j=2;j<i;j++)
{
broj+=dp2[j+1];
broj%=mod;
dp[j]=0;
dp[j]=broj;
dp[j]%=mod;
dp2[j]=dp2[j-1]+dp[j];
dp2[j]%=mod;
}
}
brojac+=v[n-1];
brojac%=mod;
cout<<brojac<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
488 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
488 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
488 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
28 ms |
2192 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
98 ms |
7232 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1026 ms |
65536 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1073 ms |
65536 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1059 ms |
65536 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |