# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
547771 | nonsensenonsense1 | Misspelling (JOI22_misspelling) | C++17 | 4017 ms | 7036 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <utility>
#include <algorithm>
const int md = 1000000007;
inline int add(int a, int b) {
a += b;
if (a >= md) a -= md;
return a;
}
inline int mul(int a, int b) {
return (long long)a * b % md;
}
const int A = 26;
const int N = 500000;
int n, m, d[N][A];
bool u[2][N];
std::pair<std::pair<int, int>, bool> a[N];
int main() {
scanf("%d%d", &n, &m);
for (int i = 0; i < m; ++i) {
int x, y;
scanf("%d%d", &x, &y);
--x;
--y;
if (x < y) a[i] = std::make_pair(std::make_pair(x, y), 1);
else a[i] = std::make_pair(std::make_pair(y, x), 0);
}
std::sort(a, a + m);
for (int i = n - 1, j = m - 1; i >= 0; --i) {
while (j >= 0 && a[j].first.first == i) {
for (int k = i; k < a[j].first.second; ++k) u[a[j].second][k] = 1;
--j;
}
for (int x = 0; x < A; ++x) {
d[i][x] = 1;
for (int k = i; k < n - 1; ++k)
for (int y = 0; y < A; ++y)
if (x < y && !u[1][k] || x > y && !u[0][k])
d[i][x] = add(d[i][x], d[k + 1][y]);
}
}
int ans = 0;
for (int i = 0; i < A; ++i) ans = add(ans, d[0][i]);
printf("%d\n", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |