제출 #593994

#제출 시각아이디문제언어결과실행 시간메모리
593994OttoTheDinoMisspelling (JOI22_misspelling)C++17
60 / 100
151 ms103812 KiB
#include <bits/stdc++.h>
using namespace std;

#define rep(i,s,e)                  for (int i = s; i <= e; ++i)
#define rrep(i,s,e)                 for (int i = s; i >= e; --i)
#define pb                          push_back
#define fi                          first
#define se                          second
#define len(a)                      (int)a.size()
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

const int mod = 1e9+7;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, m, c[26][2] = {}, dp[(int)2e5][26] = {}, ans = 0; cin >> n >> m;
    vii upd[n+1];
    rep (i,1,m) {
        int a, b; cin >> a >> b;
        if (a<b) upd[a].pb({b,0});
        else upd[b].pb({a,1});
    }
    vi f[2];
    rrep (i,n,1) {
        for (ii el : upd[i]) {
            while (len(f[el.se]) && f[el.se].back()<=el.fi) {
                rep (j,0,25) c[j][el.se] = (c[j][el.se]-dp[f[el.se].back()][j]+mod)%mod;
                f[el.se].pop_back();
            }
        }
        int s = 1;
        rep (j,0,25) {
            dp[i][j] = (dp[i][j]+s)%mod;
            s = (s+c[j][0])%mod;
        }
        s = 0;
        rrep (j,25,0) {
            dp[i][j] = (dp[i][j]+s)%mod;
            s = (s+c[j][1])%mod;
        }
        rep (j,0,25) {
            c[j][0] = (c[j][0] + dp[i][j])%mod;
            c[j][1] = (c[j][1] + dp[i][j])%mod;
        }
        f[0].pb(i), f[1].pb(i);
    }
    rep (i,0,25) ans = (ans + dp[1][i]) % mod;
    cout << ans << "\n";

    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...