Submission #794578

#TimeUsernameProblemLanguageResultExecution timeMemory
794578vjudge1Misspelling (JOI22_misspelling)C++17
28 / 100
47 ms524 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][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][c] = 1; for(int i = 2; i <= n; i++) { for(int c = 0; c < 26; c++) { dp[i][c] = 0; int sm = 0, gr = 0; for(int k = i - 1; k >= 1; k--) { sm = max(sm, sml[k]); gr = max(gr, grt[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][c] += dp[k][d]; dp[i][c] %= MOD; } } else { if(gr < i || d > c){ dp[i][c] += dp[k][d]; dp[i][c] %= MOD; } } } } } } ll ans = 0; for(int i = 1; i <= n; i++) { for(int c = 0;c < 26; c++) { ans += dp[i][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...