Submission #880115

#TimeUsernameProblemLanguageResultExecution timeMemory
880115DAleksaMisspelling (JOI22_misspelling)C++17
28 / 100
1065 ms9308 KiB
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int add(int x, int y) { x += y; return x >= mod ? x - mod : x; } void sadd(int& x, int y) { x = add(x, y); } const int N = 210; int n, m; int a[N], b[N]; int dp[N][N][26]; int cnt[N][N][2]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for(int i = 0; i < m; i++) { cin >> a[i] >> b[i]; for(int j = min(a[i], b[i]); j < max(a[i], b[i]); j++) { for(int len = 1; len <= n; len++) { if(j - len + 1 > min(a[i], b[i])) continue; if(j < len) break; if(a[i] < b[i]) cnt[j][len][0]++; else cnt[j][len][1]++; } } } for(int i = 1; i <= n; i++) for(int j = 0; j < 26; j++) dp[i][i][j] = 1; for(int i = 2; i <= n; i++) { for(int len = 1; len <= i; len++) { for(int c = 0; c < 26; c++) { for(int j = 1; j <= i - len; j++) { if(cnt[i - len][j][0] == 0 && cnt[i - len][j][1] == 0) { for(int c2 = 0; c2 < c; c2++) sadd(dp[i][len][c], dp[i - len][j][c2]); for(int c2 = c + 1; c2 < 26; c2++) sadd(dp[i][len][c], dp[i - len][j][c2]); } else if(cnt[i - len][j][0] > 0 && cnt[i - len][j][1] == 0) { for(int c2 = c + 1; c2 < 26; c2++) sadd(dp[i][len][c], dp[i - len][j][c2]); } else if(cnt[i - len][j][0] == 0 && cnt[i - len][j][1] > 0) { for(int c2 = 0; c2 < c; c2++) sadd(dp[i][len][c], dp[i - len][j][c2]); } else break; } } } } int ans = 0; for(int len = 1; len <= n; len++) for(int c = 0; c < 26; c++) sadd(ans, dp[n][len][c]); cout << ans; return 0; }
#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...