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 <bits/stdc++.h>
using namespace std;
const int md = (int)1e9 + 7;
void add(int& a, int b) {
a += b;
if(a >= md) a -= md;
if(a < 0) a += md;
}
const int N = 202;
int n, m, res, x[N], y[N], f[N][N][N][26];
int main() {
scanf("%d %d", &n, &m);
for(int i = 0; i < m; ++i) {
int a, b;
scanf("%d %d", &a, &b);
if(a < b) {
x[a] = max(x[a], b);
}
else {
y[b] = max(y[b], a);
}
}
f[0][0][0][0] = 1;
f[0][0][0][1] = -1;
for(int i = 0; i < n; ++i) {
for(int j = 0; j <= n; ++j) {
for(int k = 0; k <= n; ++k) {
for(int c = 1; c < 26; ++c) {
add(f[i][j][k][c], f[i][j][k][c - 1]);
}
for(int c = 0; c < 26; ++c) {
int ft = f[i][j][k][c];
if(ft == 0) continue;
add(f[i + 1][max(j, x[i + 1])][max(k, y[i + 1])][c], ft);
if(c < 25) add(f[i + 1][max(j, x[i + 1])][max(k, y[i + 1])][c + 1], -ft);
if(i >= j) {
add(f[i + 1][x[i + 1]][y[i + 1]][0], ft);
add(f[i + 1][x[i + 1]][y[i + 1]][c], -ft);
}
if(i >= k) {
if(c < 25) {
add(f[i + 1][x[i + 1]][y[i + 1]][c + 1], ft);
}
}
}
}
}
}
res = 0;
for(int i = 0; i <= n; ++i) {
for(int j = 0; j <= n; ++j) {
for(int c = 0; c < 26; ++c) {
if(c) add(f[n][i][j][c], f[n][i][j][c - 1]);
add(res, f[n][i][j][c]);
}
}
}
printf("%d", res);
return 0;
}
Compilation message (stderr)
misspelling.cpp: In function 'int main()':
misspelling.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
16 | scanf("%d %d", &n, &m);
| ~~~~~^~~~~~~~~~~~~~~~~
misspelling.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
19 | scanf("%d %d", &a, &b);
| ~~~~~^~~~~~~~~~~~~~~~~
# | 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... |