답안 #257941

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
257941 2020-08-05T05:35:13 Z daniel920712 Boat (APIO16_boat) C++14
9 / 100
2000 ms 8472 KB
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <time.h>

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 F2(long long x,long long y)
{
    long long i;
    //printf("%lld %lld\n",x,y);
    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)]=F2(x-1,y);
    for(i=a[x];i<=min(b[x],y-1);i++)
    {
        all[make_pair(x,y)]+=F2(x-1,i);
        all[make_pair(x,y)]%=MOD;
    }

    return all[make_pair(x,y)];
}
int main()
{
    
    srand(time(NULL));
    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(a[i]+1);
        have.insert(b[i]);
        have.insert(b[i]+1);
    }
    for(auto i:have)
    {
        if(i==*prev(have.end()))
        {
            con[i]=1;
            r[i]=i;
        }
        if(have.lower_bound(i)!=have.begin())
        {
            con[*prev(have.lower_bound(i))]=i-*prev(have.lower_bound(i));
            r[*prev(have.lower_bound(i))]=i-1;
        }
    }
    printf("%lld\n",F2(N,1e9+5));
    return 0;
}
/*
2
32 47
18 78
*/


Compilation message

boat.cpp: In function 'int main()':
boat.cpp:35:17: warning: unused variable 'M' [-Wunused-variable]
     long long N,M,i;
                 ^
boat.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&N);
     ~~~~~^~~~~~~~~~~
boat.cpp:39: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]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 86 ms 8440 KB Output is correct
2 Correct 87 ms 8440 KB Output is correct
3 Correct 86 ms 8440 KB Output is correct
4 Correct 85 ms 8444 KB Output is correct
5 Correct 90 ms 8440 KB Output is correct
6 Correct 114 ms 8440 KB Output is correct
7 Correct 112 ms 8440 KB Output is correct
8 Correct 112 ms 8400 KB Output is correct
9 Correct 132 ms 8416 KB Output is correct
10 Correct 124 ms 8380 KB Output is correct
11 Correct 109 ms 8440 KB Output is correct
12 Correct 116 ms 8444 KB Output is correct
13 Correct 119 ms 8472 KB Output is correct
14 Correct 113 ms 8440 KB Output is correct
15 Correct 111 ms 8440 KB Output is correct
16 Correct 23 ms 2680 KB Output is correct
17 Correct 24 ms 2680 KB Output is correct
18 Correct 23 ms 2680 KB Output is correct
19 Correct 23 ms 2688 KB Output is correct
20 Correct 24 ms 2680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 86 ms 8440 KB Output is correct
2 Correct 87 ms 8440 KB Output is correct
3 Correct 86 ms 8440 KB Output is correct
4 Correct 85 ms 8444 KB Output is correct
5 Correct 90 ms 8440 KB Output is correct
6 Correct 114 ms 8440 KB Output is correct
7 Correct 112 ms 8440 KB Output is correct
8 Correct 112 ms 8400 KB Output is correct
9 Correct 132 ms 8416 KB Output is correct
10 Correct 124 ms 8380 KB Output is correct
11 Correct 109 ms 8440 KB Output is correct
12 Correct 116 ms 8444 KB Output is correct
13 Correct 119 ms 8472 KB Output is correct
14 Correct 113 ms 8440 KB Output is correct
15 Correct 111 ms 8440 KB Output is correct
16 Correct 23 ms 2680 KB Output is correct
17 Correct 24 ms 2680 KB Output is correct
18 Correct 23 ms 2680 KB Output is correct
19 Correct 23 ms 2688 KB Output is correct
20 Correct 24 ms 2680 KB Output is correct
21 Execution timed out 2076 ms 1564 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2086 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 86 ms 8440 KB Output is correct
2 Correct 87 ms 8440 KB Output is correct
3 Correct 86 ms 8440 KB Output is correct
4 Correct 85 ms 8444 KB Output is correct
5 Correct 90 ms 8440 KB Output is correct
6 Correct 114 ms 8440 KB Output is correct
7 Correct 112 ms 8440 KB Output is correct
8 Correct 112 ms 8400 KB Output is correct
9 Correct 132 ms 8416 KB Output is correct
10 Correct 124 ms 8380 KB Output is correct
11 Correct 109 ms 8440 KB Output is correct
12 Correct 116 ms 8444 KB Output is correct
13 Correct 119 ms 8472 KB Output is correct
14 Correct 113 ms 8440 KB Output is correct
15 Correct 111 ms 8440 KB Output is correct
16 Correct 23 ms 2680 KB Output is correct
17 Correct 24 ms 2680 KB Output is correct
18 Correct 23 ms 2680 KB Output is correct
19 Correct 23 ms 2688 KB Output is correct
20 Correct 24 ms 2680 KB Output is correct
21 Execution timed out 2076 ms 1564 KB Time limit exceeded
22 Halted 0 ms 0 KB -