제출 #602503

#제출 시각아이디문제언어결과실행 시간메모리
602503SamAndMisspelling (JOI22_misspelling)C++17
28 / 100
13 ms480 KiB
#include <bits/stdc++.h> using namespace std; #define m_p make_pair #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) #define fi first #define se second typedef long long ll; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); mt19937 rnf(2106); const int N = 203, M = 1000000007; int n, m; int a[N]; vector<int> v[N]; int dp[N][26][2]; void solv() { cin >> n >> m; for (int i = 1; i <= m; ++i) { int x, y; cin >> x >> y; if (x == y) continue; if (x < y) { v[x].push_back(y); } else { v[y].push_back(-x); } } for (int k = 0; k < 26; ++k) dp[n][k][0] = 1; for (int i = n - 1; i >= 1; --i) { int s[26] = {}; for (int k = 0; k < 26; ++k) { for (int j = i + 1; j <= n; ++j) { s[k] = (s[k] + dp[j][k][0]) % M; s[k] = (s[k] + dp[j][k][1]) % M; } } for (int k = 0; k < 26; ++k) { for (int u = k + 1; u < 26; ++u) dp[i][k][1] = (dp[i][k][1] + s[u]) % M; for (int u = 0; u < k; ++u) dp[i][k][0] = (dp[i][k][0] + s[u]) % M; } for(int t = 0; t < sz(v[i]); ++t) { if (v[i][t] > 0) { for (int j = i; j < v[i][t]; ++j) { for (int k = 0; k < 26; ++k) { dp[j][k][1] = 0; } } } else { for (int j = i; j < -v[i][t]; ++j) { for (int k = 0; k < 26; ++k) { dp[j][k][0] = 0; } } } } } int ans = 0; for (int i = 1; i <= n; ++i) { for (int k = 0; k < 26; ++k) { for (int z = 0; z < 2; ++z) { ans = (ans + dp[i][k][z]) % M; } } } cout << ans << "\n"; } int main() { #ifdef SOMETHING freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); #endif // SOMETHING ios_base::sync_with_stdio(false), cin.tie(0); int tt = 1; //cin >> tt; while (tt--) { solv(); } 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...