제출 #848658

#제출 시각아이디문제언어결과실행 시간메모리
848658danikoynovMisspelling (JOI22_misspelling)C++14
28 / 100
4050 ms17148 KiB
/** ____ ____ ____ ____ ____ ____ ||l |||e |||i |||n |||a |||d || ||__|||__|||__|||__|||__|||__|| |/__\|/__\|/__\|/__\|/__\|/__\| **/ #include<bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } const ll mod = 1000000007; const int maxm = 5e5 + 10; const int maxn = 210; int n, m; ll dp[maxn][maxn][30]; pair < int, int > con[maxm]; void solve() { cin >> n >> m; for (int i = 1; i <= m; i ++) { cin >> con[i].first >> con[i].second; } for (int j = 0; j < 26; j ++) { dp[1][1][j] = 1; } for (int i = 1; i <= n - 1; i ++) { for (int j = 1; j <= i; j ++) { bool small = false, big = false; for (int d = 1; d <= m; d ++) { if (con[d].first == con[d].second) continue; if (con[d].first < con[d].second) { if (con[d].first >= i + 1 || con[d].second < i + 1) continue; if (i - j < con[d].first) small = true; } else { if (con[d].second >= i + 1 || con[d].first < i + 1) continue; if (i - j < con[d].second) big = true; } } ///cout << small << " : " << big << endl; if (!small) { ll sum = 0; for (int c = 0; c < 26; c ++) { dp[i + 1][1][c] += sum; if (dp[i + 1][1][c] >= mod) dp[i + 1][1][c] -= mod; sum += dp[i][j][c]; if (sum >= mod) sum -= mod; } } if (!big) { ll sum = 0; for (int c = 25; c >= 0; c --) { dp[i + 1][1][c] += sum; if (dp[i + 1][1][c] >= mod) dp[i + 1][1][c] -= mod; sum += dp[i][j][c]; if (sum >= mod) sum -= mod; } } for (int c = 0; c < 26; c ++) { dp[i + 1][j + 1][c] += dp[i][j][c]; if (dp[i + 1][j + 1][c] >= mod) dp[i + 1][j + 1][c] -= mod; } } } ll ans = 0; for (int j = 1; j <= n; j ++) for (int c = 0; c < 26; c ++) { ans = ans + dp[n][j][c]; if (ans >= mod) ans -= mod; } cout << ans << endl; } int main() { solve(); 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...