Submission #238057

#TimeUsernameProblemLanguageResultExecution timeMemory
238057SortingLucky Numbers (RMI19_lucky)C++14
28 / 100
17 ms2432 KiB
#include <bits/stdc++.h> using namespace std; const int k_Mod = 1e9 + 7; const int k_N = 1e5 + 7; int n, q; string x; pair<int, int> dp[k_N][10][2]; int iteration; int solve(int digits_left, int previous_digit, bool equal, int end){ if(digits_left == 0) return 1; auto &[answer, solved] = dp[digits_left][previous_digit][equal]; if(solved == iteration) return answer; solved = iteration; answer = 0; int max_digit = 9; if(equal){ int position = end - digits_left + 1; max_digit = x[position] - '0'; } for(int digit = 0; digit <= max_digit; ++digit){ if(previous_digit == 1 && digit == 3) continue; bool new_equal = equal ? (digit == max_digit) : false; answer += solve(digits_left - 1, digit, new_equal, end); answer = (answer >= k_Mod) ? (answer - k_Mod) : answer; } return answer; } int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> q; cin >> x; iteration = 1; cout << solve(n, 0, true, n - 1) << "\n"; for(int i = 0; i < q; ++i){ int t; cin >> t; if(t == 1){ int l, r; cin >> l >> r; --l, --r; cout << solve(r - l + 1, 0, true, r) << "\n"; } else{ int position; char value; cin >> position >> value; --position; x[position] = value; ++iteration; } } }

Compilation message (stderr)

lucky.cpp: In function 'int solve(int, int, bool, int)':
lucky.cpp:18:11: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
     auto &[answer, solved] = dp[digits_left][previous_digit][equal];
           ^
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...