# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
258656 | 2020-08-06T10:28:40 Z | dantoh000 | Lucky Numbers (RMI19_lucky) | C++14 | 200 ms | 7560 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mod = 1000000007; ll mem[100005][2]; int a[100005]; int n,q; ll dp(int id, int lastone){ if (id == 0) return 1; if (mem[id][lastone] != -1) return mem[id][lastone]; ll ret = 0; for (int i = 0; i < 10; i++){ if (lastone && i == 3) continue; ret += dp(id-1,i==1); } ret %= mod; //printf("%d %d %lld\n",id,lastone,ret); return mem[id][lastone] = ret; } ll qu(int l, int r){ ll ret = 0; int ct = r-l; bool isthirteenalready = false; for (int i = l; i <= r; i++, ct--){ if (isthirteenalready) continue; for (int j = 0; j < a[i]; j++){ if (i != l && a[i-1] == 1 && j == 3) continue; ret += dp(ct,j==1); if (ret >= mod) ret -= mod; } if (i != l && a[i-1] == 1 && a[i] == 3) isthirteenalready = true; } if (!isthirteenalready) ret++; if (ret >= mod) ret -= mod; return ret; } int main(){ scanf("%d%d",&n,&q); for (int i = 0; i < n; i++){ char ch; scanf(" %c",&ch); a[i] = ch-'0'; } memset(mem,-1,sizeof(mem)); printf("%lld\n",qu(0,n-1)); for (int i = 0; i < q; i++){ int t,l,r; scanf("%d%d%d",&t,&l,&r); if (t == 1){ printf("%lld\n",qu(--l,--r)); } else{ a[--l] = r; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1920 KB | Output is correct |
2 | Correct | 1 ms | 1920 KB | Output is correct |
3 | Correct | 1 ms | 1792 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1920 KB | Output is correct |
2 | Correct | 1 ms | 1920 KB | Output is correct |
3 | Correct | 1 ms | 1792 KB | Output is correct |
4 | Correct | 1 ms | 1920 KB | Output is correct |
5 | Correct | 1 ms | 1920 KB | Output is correct |
6 | Correct | 1 ms | 1920 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 2488 KB | Output is correct |
2 | Correct | 58 ms | 2808 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 2488 KB | Output is correct |
2 | Correct | 58 ms | 2808 KB | Output is correct |
3 | Execution timed out | 228 ms | 7560 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1920 KB | Output is correct |
2 | Correct | 1 ms | 1920 KB | Output is correct |
3 | Correct | 1 ms | 1792 KB | Output is correct |
4 | Correct | 1 ms | 1920 KB | Output is correct |
5 | Correct | 1 ms | 1920 KB | Output is correct |
6 | Correct | 1 ms | 1920 KB | Output is correct |
7 | Correct | 37 ms | 2488 KB | Output is correct |
8 | Correct | 58 ms | 2808 KB | Output is correct |
9 | Correct | 20 ms | 2560 KB | Output is correct |
10 | Correct | 32 ms | 2688 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1920 KB | Output is correct |
2 | Correct | 1 ms | 1920 KB | Output is correct |
3 | Correct | 1 ms | 1792 KB | Output is correct |
4 | Correct | 1 ms | 1920 KB | Output is correct |
5 | Correct | 1 ms | 1920 KB | Output is correct |
6 | Correct | 1 ms | 1920 KB | Output is correct |
7 | Correct | 37 ms | 2488 KB | Output is correct |
8 | Correct | 58 ms | 2808 KB | Output is correct |
9 | Execution timed out | 228 ms | 7560 KB | Time limit exceeded |
10 | Halted | 0 ms | 0 KB | - |