Submission #76734

# Submission time Handle Problem Language Result Execution time Memory
76734 2018-09-16T22:44:04 Z vex Boat (APIO16_boat) C++14
0 / 100
8 ms 4824 KB
#include <bits/stdc++.h>
#define maxn 505
#define f first
#define s second
#define pii pair<int,int>
#define mod (long long)(1e9 + 7)
using namespace std;

int n;
int a[maxn][2];
pair<pii,int> d[2*maxn];
int pl[maxn];
int pr[maxn];
long long dp[2*maxn][maxn];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i][0]>>a[i][1];
        d[2*i-1]={{a[i][0],0},i};
        d[2*i]={{a[i][1],1},i};
    }

    sort(d+1,d+2*n+1);
    for(int i=1;i<=2*n;i++)
    {
        if(d[i].f.s==0) pl[ d[i].s ]=i;
        else pr[ d[i].s ]=i;
    }

    for(int i=1;i<=n;i++)dp[0][i]=0;
    dp[0][0]=1;
    dp[0][d[1].s]=1;

    for(int i=1;i<=2*n-1;i++)
    {
        dp[i][0]=1;
        for(int j=1;j<=n;j++)
        {
            dp[i][j]=dp[i-1][j];
            int dod=0;

            if(d[i].f.f==d[i+1].f.f)continue;

            if(pl[j]==i+1)dod=1;
            else if(pl[j]<=i && i+1<=pr[j])dod=d[i+1].f.f-d[i].f.f;
            else continue;

            //cout<<i<<"    "<<j<<" "<<dod<<endl;

            for(int k=0;k<j;k++)
            {
                dp[i][j]+=dp[i-1][k]*dod;
                dp[i][j]%=mod;
            }
        }
    }

    long long sol=0;
    for(int i=1;i<=n;i++)
    {
        sol+=dp[2*n-1][i];
        sol%=mod;
    }

    /*for(int i=1;i<=2*n;i++)cout<<d[i].f.f<<" "<<d[i].f.s<<" "<<d[i].s<<endl;cout<<endl;
    for(int i=1;i<=n;i++)cout<<i<<"   "<<pl[i]<<" "<<pr[i]<<endl;cout<<endl;
    for(int i=0;i<=2*n-1;i++)
    {
        cout<<i<<"    ";
        for(int j=0;j<=n;j++)cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/

    cout<<sol<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4348 KB Output is correct
2 Correct 7 ms 4480 KB Output is correct
3 Correct 7 ms 4616 KB Output is correct
4 Correct 7 ms 4616 KB Output is correct
5 Correct 7 ms 4684 KB Output is correct
6 Correct 6 ms 4696 KB Output is correct
7 Correct 6 ms 4708 KB Output is correct
8 Correct 6 ms 4720 KB Output is correct
9 Correct 6 ms 4720 KB Output is correct
10 Correct 6 ms 4744 KB Output is correct
11 Correct 6 ms 4756 KB Output is correct
12 Correct 6 ms 4768 KB Output is correct
13 Correct 8 ms 4780 KB Output is correct
14 Correct 6 ms 4796 KB Output is correct
15 Correct 6 ms 4808 KB Output is correct
16 Incorrect 6 ms 4824 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4348 KB Output is correct
2 Correct 7 ms 4480 KB Output is correct
3 Correct 7 ms 4616 KB Output is correct
4 Correct 7 ms 4616 KB Output is correct
5 Correct 7 ms 4684 KB Output is correct
6 Correct 6 ms 4696 KB Output is correct
7 Correct 6 ms 4708 KB Output is correct
8 Correct 6 ms 4720 KB Output is correct
9 Correct 6 ms 4720 KB Output is correct
10 Correct 6 ms 4744 KB Output is correct
11 Correct 6 ms 4756 KB Output is correct
12 Correct 6 ms 4768 KB Output is correct
13 Correct 8 ms 4780 KB Output is correct
14 Correct 6 ms 4796 KB Output is correct
15 Correct 6 ms 4808 KB Output is correct
16 Incorrect 6 ms 4824 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4824 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4348 KB Output is correct
2 Correct 7 ms 4480 KB Output is correct
3 Correct 7 ms 4616 KB Output is correct
4 Correct 7 ms 4616 KB Output is correct
5 Correct 7 ms 4684 KB Output is correct
6 Correct 6 ms 4696 KB Output is correct
7 Correct 6 ms 4708 KB Output is correct
8 Correct 6 ms 4720 KB Output is correct
9 Correct 6 ms 4720 KB Output is correct
10 Correct 6 ms 4744 KB Output is correct
11 Correct 6 ms 4756 KB Output is correct
12 Correct 6 ms 4768 KB Output is correct
13 Correct 8 ms 4780 KB Output is correct
14 Correct 6 ms 4796 KB Output is correct
15 Correct 6 ms 4808 KB Output is correct
16 Incorrect 6 ms 4824 KB Output isn't correct
17 Halted 0 ms 0 KB -