#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
const ll MAXN=1e5+6;
ll dp[MAXN];
int n,q;
ll a[MAXN];
ll solve(int l,int r)
{
ll ans=0;
for(int i=l;i<=r;i++)
{
if(i>l+1&&a[i-2]==1&&a[i-1]==3)break;
ans+=a[i]*dp[r-i];
if(a[i]>1&&i<r)ans-=dp[r-i-1];
if(i!=l&&a[i-1]==1&&a[i]>3)ans-=dp[r-i];
while(ans<0)ans+=mod;
ans%=mod;
//cout<<i<<" "<<a[i]<<" "<<ans<<endl;
}
bool flag=1;
for(int i=l;i+1<=r;i++)
{
if(a[i]==1&&a[i+1]==3)flag=0;
}
if(flag)ans++;
ans%=mod;
return ans;
}
void precompute()
{
dp[0]=1;
dp[1]=10;
for(int i=2;i<MAXN;i++)
{
dp[i]=dp[i-1]*10ll-dp[i-2];
dp[i]+=mod;
dp[i]%=mod;
}
}
int main()
{
cin>>n>>q;
precompute();
for(int i=1;i<=n;i++)
{
char c;
cin>>c;
a[i]=c-'0';
}
cout<<solve(1,n)<<endl;
for(int i=0;i<q;i++)
{
int t,x,y;
cin>>t>>x>>y;
if(t==1)cout<<solve(x,y)<<endl;
else a[x]=y;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
980 KB |
Output is correct |
2 |
Correct |
1 ms |
980 KB |
Output is correct |
3 |
Correct |
1 ms |
980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
980 KB |
Output is correct |
2 |
Correct |
1 ms |
980 KB |
Output is correct |
3 |
Correct |
1 ms |
980 KB |
Output is correct |
4 |
Correct |
1 ms |
980 KB |
Output is correct |
5 |
Correct |
1 ms |
980 KB |
Output is correct |
6 |
Correct |
1 ms |
980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
52 ms |
1120 KB |
Output is correct |
2 |
Correct |
77 ms |
1336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
52 ms |
1120 KB |
Output is correct |
2 |
Correct |
77 ms |
1336 KB |
Output is correct |
3 |
Execution timed out |
373 ms |
2172 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
980 KB |
Output is correct |
2 |
Correct |
1 ms |
980 KB |
Output is correct |
3 |
Correct |
1 ms |
980 KB |
Output is correct |
4 |
Correct |
1 ms |
980 KB |
Output is correct |
5 |
Correct |
1 ms |
980 KB |
Output is correct |
6 |
Correct |
1 ms |
980 KB |
Output is correct |
7 |
Correct |
52 ms |
1120 KB |
Output is correct |
8 |
Correct |
77 ms |
1336 KB |
Output is correct |
9 |
Correct |
28 ms |
1212 KB |
Output is correct |
10 |
Correct |
41 ms |
1280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
980 KB |
Output is correct |
2 |
Correct |
1 ms |
980 KB |
Output is correct |
3 |
Correct |
1 ms |
980 KB |
Output is correct |
4 |
Correct |
1 ms |
980 KB |
Output is correct |
5 |
Correct |
1 ms |
980 KB |
Output is correct |
6 |
Correct |
1 ms |
980 KB |
Output is correct |
7 |
Correct |
52 ms |
1120 KB |
Output is correct |
8 |
Correct |
77 ms |
1336 KB |
Output is correct |
9 |
Execution timed out |
373 ms |
2172 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |