// Hallelujah, praise the one who set me free
// Hallelujah, death has lost its grip on me
// You have broken every chain, There's salvation in your name
// Jesus Christ, my living hope
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
template <class T>
inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;}
#define REP(i, s, e) for (int i = s; i < e; i++)
#define RREP(i, s, e) for (int i = s; i >= e; i--)
typedef long long ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define SZ(_a) (int) _a.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<iii> viii;
#ifndef DEBUG
#define cerr if (0) cerr
#endif
const int INF = 1000000005;
const ll LINF = 1000000000000000005ll;
const int MAXN = 20005;
const int MOD = 1000000007;
int n, m;
int lr[MAXN][2];
ll dp[2][MAXN][30];
ll ans;
int main() {
#ifndef DEBUG
ios::sync_with_stdio(0), cin.tie(0);
#endif
cin >> n >> m;
REP (i, 0, m) {
int a, b; cin >> a >> b;
bool s = 0;
if (a > b) {
s = 1;
swap(a, b);
}
mxto(lr[a][s], b);
}
int cur = 1, prv = 0;
REP (c, 0, 26) {
dp[cur][1][c] = 1;
}
REP (i, 2, n + 1) {
swap(cur, prv);
int r[2] = {0, 0};
RREP (j, i - 1, 1) {
REP (z, 0, 2) {
mxto(r[z], lr[j][z]);
}
ll lsm = 0, rsm = 0;
REP (c, 0, 26) {
rsm += dp[prv][j][c];
if (rsm >= MOD) {
rsm -= MOD;
}
// stay the same
dp[cur][j][c] = dp[prv][j][c];
}
bool za = r[0] < i, zb = r[1] < i;
REP (c, 0, 26) {
rsm -= dp[prv][j][c];
if (rsm < 0) {
rsm += MOD;
}
if (za) {
dp[cur][i][c] += rsm;
if (dp[cur][i][c] >= MOD) {
dp[cur][i][c] -= MOD;
}
}
if (zb) {
dp[cur][i][c] += lsm;
if (dp[cur][i][c] >= MOD) {
dp[cur][i][c] -= MOD;
}
}
lsm += dp[prv][j][c];
if (lsm >= MOD) {
lsm -= MOD;
}
}
}
}
REP (j, 1, n + 1) {
REP (c, 0, 26) {
ans += dp[cur][j][c];
if (ans >= MOD) {
ans -= MOD;
}
}
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |