Submission #794003

#TimeUsernameProblemLanguageResultExecution timeMemory
794003vjudge1Misspelling (JOI22_misspelling)C++17
28 / 100
78 ms11212 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const int N = 210; const int MOD = 1e9 + 7; int grt[N] = {}, sml[N] = {}; ll dp[N][N][26]; int main() { ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int n, m; cin >> n >> m; for(int i = 0; i < m; i++) { int a, b; cin >> a >> b; if(a < b) { grt[a] = max(grt[a], b); } else { sml[b] = max(sml[b], a); } } for(int c = 0; c < 26; c++) dp[1][0][c] = 1; for(int i = 2; i <= n; i++) { for(int c = 0; c < 26; c++) { for(int j = 1; j <= i; j++) dp[i][j][c] = dp[i - 1][j - 1][c]; dp[i][0][c] = 0; int sm = 0, gr = 0; for(int k = 0; k < i; k++) { sm = max(sm, sml[i - 1 - k]); gr = max(gr, grt[i - 1 - k]); if(sm >= i && gr >= i) break; for(int d = 0; d < 26; d++) { if(d == c) continue; if(sm >= i) { if(d < c) { dp[i][0][c] += dp[i - 1][k][d]; dp[i][0][c] %= MOD; } } else { if(gr < i || d > c){ dp[i][0][c] += dp[i - 1][k][d]; dp[i][0][c] %= MOD; } } } } } } ll ans = 0; for(int c = 0;c < 26; c++) { for(int k = 0; k <= n; k++) { ans += dp[n][k][c]; ans %= MOD; } } cout << ans; }
#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...