Salesforce Workflow ConfigurationGiven a Salesforc...
Criado em: 23 de janeiro de 2026
Respondido usando GPT-5.2 Thinking por Chat01
Criado em: 23 de janeiro de 2026
Respondido usando GPT-5.2 Thinking por Chat01
Salesforce Workflow ConfigurationGiven a Salesforce workflow configuration string config consisting of digits (0-9) and placeholders (?), determine the number of ways the placeholders can be replaced with digits (0-9) such that no two adjacent workflow steps (digits) are the same.Note: Since the answer can be very large, return the answer modulo .ExampleGiven the workflow configuration string config = "1?3?":The first placeholder (?) can be replaced with 8 possible digits: {2, 4, 5, 6, 7, 8, 9, 0} (all digits except 1 and 3).The second placeholder can be replaced with 9 possible digits: {1, 2, 4, 5, 6, 7, 8, 9, 0} (all digits except 3).This results in a total of 72 possible configurations.Since the total number of configurations may be very large, return the result modulo .Function DescriptionComplete the function getWorkflowReplacements in the editor below.getWorkflowReplacements has the following parameter(s):string config: The workflow configuration string consisting of digits (0-9) and placeholders (?).Returnint: The total number of valid configurations modulo .ConstraintsThe string config consists of digits from '0' to '9' and '?' only.Code Editor (C++14)C++#include <bits/stdc++.h>
/*
int getWorkflowReplacements(string config) {
}
int main() ... give me cpp code
cpp#include <bits/stdc++.h> using namespace std; static const long long MOD = 1000000007LL; int getWorkflowReplacements(string config) { const int DIG = 10; int n = (int)config.size(); vector<long long> prev(DIG, 0), cur(DIG, 0); // Initialize for position 0 if (config[0] == '?') { for (int d = 0; d < DIG; d++) prev[d] = 1; } else { prev[config[0] - '0'] = 1; } for (int i = 1; i < n; i++) { fill(cur.begin(), cur.end(), 0); long long total = 0; for (int d = 0; d < DIG; d++) { total += prev[d]; if (total >= MOD) total -= MOD; } if (config[i] == '?') { for (int d = 0; d < DIG; d++) { long long val = total - prev[d]; if (val < 0) val += MOD; cur[d] = val; } } else { int k = config[i] - '0'; long long val = total - prev[k]; if (val < 0) val += MOD; cur[k] = val; } prev.swap(cur); } long long ans = 0; for (int d = 0; d < DIG; d++) { ans += prev[d]; if (ans >= MOD) ans -= MOD; } return (int)ans; } // If you need a runnable program: int main() { ios::sync_with_stdio(false); cin.tie(nullptr); string config; cin >> config; cout << getWorkflowReplacements(config) << "\n"; return 0; }