为什么只有10分?
查看原帖
为什么只有10分?
525011
hide_on_dirt楼主2021/10/28 16:13
/*made in dirt & sand */
#include <bits/stdc++.h>
#include <deque>
#define lowbit(x) (x&-x)
#define bug(a) cout << a << endl;
#define mem(a, b) memset(a, b, sizeof a)
#define bug2(a, b) cout << a << ' ' << b << endl;
#define bug3(a, b, c) cout << a << ' ' << b << ' ' << c << endl;
#define pb push_back
#define int long long
#define x first
#define y second
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 1e6 + 10, M = 1e7 + 10;
const int inf = 1e-6;
int i, j, k, n, m,l, x, y, b[N];
vector<int>mp[N];
int f[N],a[N];
signed main()
{
    // freopen("black.in","r",stdin);
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>l>>n>>m;
    while (m--)
    {
        cin>>x>>y;
        mp[x].pb(y);
        b[x]++;
    }
    for(i=1;i<=n;i++)
    {
        int now=1+b[i];
        for(auto j:mp[i])
        {
            now=((now+(a[i-1]-a[j-1])%mod)%mod+mod)%mod;
        }
        f[i]=now;
        a[i]=((a[i-1]+f[i])%mod+mod)%mod;
    }
    cout<<a[n]<<endl;
     
}
2021/10/28 16:13
加载中...