Submission #32229

# Submission time Handle Problem Language Result Execution time Memory
32229 2017-10-05T02:13:12 Z dqhungdl Boat (APIO16_boat) C++14
9 / 100
146 ms 393076 KB
#include <bits/stdc++.h>
using namespace std;

typedef pair<int,int> ii;
const int mod=1e9+7;
ii Seg[505];
int n,Count=0,res=0,a[505],b[505],f[505],tree[100000005];
map<int,int> mm;

void Sub1()
{
    for(int i=1; i<=n; i++)
    {
        f[i]=1;
        for(int j=1; j<i; j++)
            if(a[j]<a[i])
                f[i]=(f[i]+f[j])%mod;
        res=(res+f[i])%mod;
    }
    cout<<res;
}

void Update(int idx,int data)
{
    while(idx<=Count)
    {
        tree[idx]=(tree[idx]+data)%mod;
        idx+=idx&-idx;
    }
}

int Query(int idx)
{
    int rs=0;
    while(idx>0)
    {
        rs=(rs+tree[idx])%mod;
        idx-=idx&-idx;
    }
    return rs;
}

void Sub2()
{
    for(int i=1; i<=n; i++)
        Seg[i]=ii(a[i],b[i]);
    sort(Seg+1,Seg+n+1);
    for(int i=1; i<=n; i++)
        for(int j=max(Seg[i-1].second,Seg[i].first); j<=Seg[i].second; j++)
            mm[j]=++Count;
    for(int i=1; i<=n; i++)
        for(int j=b[i]; j>=a[i]; j--)
        {
            int jj=mm[j];
            int tmp=Query(jj-1)+1;
            Update(jj,tmp);
            res=(res+tmp)%mod;
        }
    cout<<res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("BOAT.INP","r",stdin);
    cin>>n;
    int maxn=0;
    bool check=false;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i]>>b[i];
        if(a[i]!=b[i])
            check=true;
        maxn=max(maxn,b[i]-a[i]);
    }
    if(check==false)
        Sub1();
    else if(maxn<=1e6)
        Sub2();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 392812 KB Output is correct
2 Correct 0 ms 392812 KB Output is correct
3 Correct 0 ms 392812 KB Output is correct
4 Correct 0 ms 392812 KB Output is correct
5 Correct 0 ms 392812 KB Output is correct
6 Correct 0 ms 392812 KB Output is correct
7 Correct 0 ms 392812 KB Output is correct
8 Correct 0 ms 392812 KB Output is correct
9 Correct 0 ms 392812 KB Output is correct
10 Correct 0 ms 392812 KB Output is correct
11 Correct 0 ms 392812 KB Output is correct
12 Correct 0 ms 392812 KB Output is correct
13 Correct 0 ms 392812 KB Output is correct
14 Correct 0 ms 392812 KB Output is correct
15 Correct 0 ms 392812 KB Output is correct
16 Correct 0 ms 392812 KB Output is correct
17 Correct 0 ms 392812 KB Output is correct
18 Correct 0 ms 392812 KB Output is correct
19 Correct 0 ms 392812 KB Output is correct
20 Correct 0 ms 392812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 392812 KB Output is correct
2 Correct 0 ms 392812 KB Output is correct
3 Correct 0 ms 392812 KB Output is correct
4 Correct 0 ms 392812 KB Output is correct
5 Correct 0 ms 392812 KB Output is correct
6 Correct 0 ms 392812 KB Output is correct
7 Correct 0 ms 392812 KB Output is correct
8 Correct 0 ms 392812 KB Output is correct
9 Correct 0 ms 392812 KB Output is correct
10 Correct 0 ms 392812 KB Output is correct
11 Correct 0 ms 392812 KB Output is correct
12 Correct 0 ms 392812 KB Output is correct
13 Correct 0 ms 392812 KB Output is correct
14 Correct 0 ms 392812 KB Output is correct
15 Correct 0 ms 392812 KB Output is correct
16 Correct 0 ms 392812 KB Output is correct
17 Correct 0 ms 392812 KB Output is correct
18 Correct 0 ms 392812 KB Output is correct
19 Correct 0 ms 392812 KB Output is correct
20 Correct 0 ms 392812 KB Output is correct
21 Incorrect 146 ms 393076 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 392812 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 392812 KB Output is correct
2 Correct 0 ms 392812 KB Output is correct
3 Correct 0 ms 392812 KB Output is correct
4 Correct 0 ms 392812 KB Output is correct
5 Correct 0 ms 392812 KB Output is correct
6 Correct 0 ms 392812 KB Output is correct
7 Correct 0 ms 392812 KB Output is correct
8 Correct 0 ms 392812 KB Output is correct
9 Correct 0 ms 392812 KB Output is correct
10 Correct 0 ms 392812 KB Output is correct
11 Correct 0 ms 392812 KB Output is correct
12 Correct 0 ms 392812 KB Output is correct
13 Correct 0 ms 392812 KB Output is correct
14 Correct 0 ms 392812 KB Output is correct
15 Correct 0 ms 392812 KB Output is correct
16 Correct 0 ms 392812 KB Output is correct
17 Correct 0 ms 392812 KB Output is correct
18 Correct 0 ms 392812 KB Output is correct
19 Correct 0 ms 392812 KB Output is correct
20 Correct 0 ms 392812 KB Output is correct
21 Incorrect 146 ms 393076 KB Output isn't correct
22 Halted 0 ms 0 KB -