Submission #257898

# Submission time Handle Problem Language Result Execution time Memory
257898 2020-08-05T03:29:14 Z daniel920712 Boat (APIO16_boat) C++14
0 / 100
2000 ms 4448 KB
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <set>
#include <map>

using namespace std;
long long MOD=1e9+7;
map < pair < long long , long long > , long long > all;
long long N;
long long a[505],b[505];
map < long long , long long > con,r;
set < long long > have;
long long F(long long x,long long y)
{
    long long i;
    if(x==0) return y!=1e9+5;
    if(all.find(make_pair(x,y))!=all.end()) return all[make_pair(x,y)];
    all[make_pair(x,y)]=F(x-1,y);
    for(auto i:con)
    {
        if(i.first>=a[x]&&r[i.first]<y&&r[i.first]<=b[x])
        {
            all[make_pair(x,y)]+=i.second*F(x-1,i.first)%MOD;
            all[make_pair(x,y)]%=MOD;
        }
    }
    return all[make_pair(x,y)];
}
int main()
{
    //freopen("1_01.in","rt",stdin);
    //freopen("1_01.txt","w+t",stdout);
    long long N,M,i;
    scanf("%lld",&N);
    for(i=1;i<=N;i++)
    {
        scanf("%lld %lld",&a[i],&b[i]);
        have.insert(a[i]);
        have.insert(b[i]);
    }
    for(auto i:have)
    {
        con[i]=1;
        r[i]=i;

        if(*prev(have.lower_bound(i))+1<i-1)
        {
            con[*prev(have.lower_bound(i))+1]=i-*prev(have.lower_bound(i))-1;
            r[*prev(have.lower_bound(i))+1]=i-1;
        }
    }
    //printf("%d\n",con.size());
    //for(auto i:con) printf("%lld %lld\n",i.first,i.second);
    printf("%lld\n",F(N,1e9+5));


    return 0;
}

Compilation message

boat.cpp: In function 'long long int F(long long int, long long int)':
boat.cpp:16:15: warning: unused variable 'i' [-Wunused-variable]
     long long i;
               ^
boat.cpp: In function 'int main()':
boat.cpp:34:17: warning: unused variable 'M' [-Wunused-variable]
     long long N,M,i;
                 ^
boat.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&N);
     ~~~~~^~~~~~~~~~~
boat.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld",&a[i],&b[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 2077 ms 4448 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2077 ms 4448 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1091 ms 2904 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2077 ms 4448 KB Time limit exceeded
2 Halted 0 ms 0 KB -