답안 #26194

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
26194 2017-06-28T10:05:10 Z Extazy Boat (APIO16_boat) C++14
9 / 100
2000 ms 7992 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 517;
const int MOD = (1e9) + 7;

int n,a[N],b[N];
map < int, int > state[N];

int recurse(int pos, int last) {
    if(pos>n) {
        return ((last!=0) ? 1 : 0);
    }
    if(state[pos].find(last)!=state[pos].end()) {
        return state[pos][last];
    }
    long long ans=recurse(pos+1,last),i;
    for(i=max(last+1,a[pos]);i<=b[pos];i++) {
        ans+=recurse(pos+1,i);
    }
    ans%=MOD;
    state[pos][last]=ans;
    return ans;
}

int main() {
    int i;
    
    scanf("%d", &n);
    for(i=1;i<=n;i++) {
        scanf("%d %d", &a[i], &b[i]);
    }
    printf("%d\n", recurse(1,0));

    return 0;
}

Compilation message

boat.cpp: In function 'int main()':
boat.cpp:30:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^
boat.cpp:32:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &a[i], &b[i]);
                                     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 7992 KB Output is correct
2 Correct 49 ms 7992 KB Output is correct
3 Correct 56 ms 7992 KB Output is correct
4 Correct 49 ms 7992 KB Output is correct
5 Correct 53 ms 7992 KB Output is correct
6 Correct 56 ms 7992 KB Output is correct
7 Correct 49 ms 7992 KB Output is correct
8 Correct 56 ms 7992 KB Output is correct
9 Correct 46 ms 7992 KB Output is correct
10 Correct 53 ms 7992 KB Output is correct
11 Correct 53 ms 7992 KB Output is correct
12 Correct 56 ms 7992 KB Output is correct
13 Correct 56 ms 7992 KB Output is correct
14 Correct 53 ms 7992 KB Output is correct
15 Correct 46 ms 7992 KB Output is correct
16 Correct 9 ms 3768 KB Output is correct
17 Correct 9 ms 3900 KB Output is correct
18 Correct 6 ms 3768 KB Output is correct
19 Correct 6 ms 3900 KB Output is correct
20 Correct 9 ms 3768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 7992 KB Output is correct
2 Correct 49 ms 7992 KB Output is correct
3 Correct 56 ms 7992 KB Output is correct
4 Correct 49 ms 7992 KB Output is correct
5 Correct 53 ms 7992 KB Output is correct
6 Correct 56 ms 7992 KB Output is correct
7 Correct 49 ms 7992 KB Output is correct
8 Correct 56 ms 7992 KB Output is correct
9 Correct 46 ms 7992 KB Output is correct
10 Correct 53 ms 7992 KB Output is correct
11 Correct 53 ms 7992 KB Output is correct
12 Correct 56 ms 7992 KB Output is correct
13 Correct 56 ms 7992 KB Output is correct
14 Correct 53 ms 7992 KB Output is correct
15 Correct 46 ms 7992 KB Output is correct
16 Correct 9 ms 3768 KB Output is correct
17 Correct 9 ms 3900 KB Output is correct
18 Correct 6 ms 3768 KB Output is correct
19 Correct 6 ms 3900 KB Output is correct
20 Correct 9 ms 3768 KB Output is correct
21 Execution timed out 2000 ms 4032 KB Execution timed out
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2000 ms 2052 KB Execution timed out
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 7992 KB Output is correct
2 Correct 49 ms 7992 KB Output is correct
3 Correct 56 ms 7992 KB Output is correct
4 Correct 49 ms 7992 KB Output is correct
5 Correct 53 ms 7992 KB Output is correct
6 Correct 56 ms 7992 KB Output is correct
7 Correct 49 ms 7992 KB Output is correct
8 Correct 56 ms 7992 KB Output is correct
9 Correct 46 ms 7992 KB Output is correct
10 Correct 53 ms 7992 KB Output is correct
11 Correct 53 ms 7992 KB Output is correct
12 Correct 56 ms 7992 KB Output is correct
13 Correct 56 ms 7992 KB Output is correct
14 Correct 53 ms 7992 KB Output is correct
15 Correct 46 ms 7992 KB Output is correct
16 Correct 9 ms 3768 KB Output is correct
17 Correct 9 ms 3900 KB Output is correct
18 Correct 6 ms 3768 KB Output is correct
19 Correct 6 ms 3900 KB Output is correct
20 Correct 9 ms 3768 KB Output is correct
21 Execution timed out 2000 ms 4032 KB Execution timed out
22 Halted 0 ms 0 KB -