Submission #37903909
Source Code Expand
/* * File created on 01/09/2023 at 11:50:23. * Link to problem: * Description: * Time complexity: O() * Space complexity: O() * Status: --- * Copyright: Ⓒ 2023 Francois Vogel */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define pii pair<int, int> #define f first #define s second #define vi vector<int> #define all(x) x.begin(), x.end() #define sz(x) (int)((x).size()) #define pb push_back #define ins insert #define cls clear #define ll long long #define ld long double typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; const int MOD = 998244353; signed main() { cin.tie(0); ios_base::sync_with_stdio(0); int n; cin >> n; string b; cin >> b; int dp [n+1][27][27]; for (int i = 0; i < 27; i++) for (int j = 0; j < 27; j++) dp[n][i][j] = 1; for (int i = n-1; i >= 0; i--) { for (int j = 0; j < 27; j++) for (int k = 0; k < 27; k++) { dp[i][j][k] = 0; for (int x = 0; x < 26; x++) if ((b[i] == '?' || b[i] == 'a'+x) && x != j && x != k) { dp[i][j][k] += dp[i+1][k][x]; dp[i][j][k] %= MOD; } } } cout << dp[0][26][26]; cout.flush(); int d = 0; d++; }
Submission Info
Submission Time | |
---|---|
Task | A - No Majority |
User | fvogel |
Language | C++ (GCC 9.2.1) |
Score | 400 |
Code Size | 1430 Byte |
Status | AC |
Exec Time | 312 ms |
Memory | 17860 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 00-sample-004.txt |
All | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 00-sample-004.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt, 01-019.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00-sample-001.txt | AC | 7 ms | 3476 KiB |
00-sample-002.txt | AC | 2 ms | 3472 KiB |
00-sample-003.txt | AC | 2 ms | 3652 KiB |
00-sample-004.txt | AC | 4 ms | 3520 KiB |
01-001.txt | AC | 2 ms | 3552 KiB |
01-002.txt | AC | 8 ms | 3876 KiB |
01-003.txt | AC | 32 ms | 6852 KiB |
01-004.txt | AC | 44 ms | 9736 KiB |
01-005.txt | AC | 60 ms | 7412 KiB |
01-006.txt | AC | 167 ms | 11072 KiB |
01-007.txt | AC | 101 ms | 17684 KiB |
01-008.txt | AC | 95 ms | 17788 KiB |
01-009.txt | AC | 154 ms | 17836 KiB |
01-010.txt | AC | 198 ms | 17848 KiB |
01-011.txt | AC | 242 ms | 17720 KiB |
01-012.txt | AC | 157 ms | 17772 KiB |
01-013.txt | AC | 204 ms | 17800 KiB |
01-014.txt | AC | 246 ms | 17860 KiB |
01-015.txt | AC | 154 ms | 17788 KiB |
01-016.txt | AC | 200 ms | 17768 KiB |
01-017.txt | AC | 246 ms | 17792 KiB |
01-018.txt | AC | 90 ms | 17724 KiB |
01-019.txt | AC | 312 ms | 17712 KiB |