답안 #68075

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
68075 2018-08-15T21:14:38 Z duality Skyscraper (JOI16_skyscraper) C++11
20 / 100
908 ms 95944 KB
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
#define MOD 1000000007

int A[100];
int *dp[1 << 14][14];
int main() {
    int i;
    int N,L;
    scanf("%d %d",&N,&L);
    for (i = 0; i < N; i++) scanf("%d",&A[i]);

    int j,k,l;
    for (i = 0; i < (1 << N); i++) {
        for (j = 0; j < N; j++) {
            dp[i][j] = new int[L+1];
            fill(dp[i][j],dp[i][j]+L+1,0);
        }
    }
    for (i = 0; i < N; i++) dp[1 << i][i][0] = 1;
    for (i = 0; i < (1 << N); i++) {
        vi v;
        for (j = 0; j < N; j++) {
            if (i & (1 << j)) v.pb(j);
        }
        if (v.size() >= 2) {
            for (j = 0; j <= L; j++) {
                for (k = 0; k < v.size(); k++) {
                    for (l = 0; l < v.size(); l++) {
                        if (k != l) {
                            if (j >= abs(A[v[k]]-A[v[l]])) {
                                dp[i][v[k]][j] += dp[i^(1 << v[k])][v[l]][j-abs(A[v[k]]-A[v[l]])];
                                dp[i][v[k]][j] %= MOD;
                            }
                        }
                    }
                }
            }
        }
    }
    int s = 0;
    for (i = 0; i < N; i++) {
        for (j = 0; j <= L; j++) s += dp[(1 << N)-1][i][j],s %= MOD;
    }
    printf("%d\n",s);


    return 0;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:33:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for (k = 0; k < v.size(); k++) {
                             ~~^~~~~~~~~~
skyscraper.cpp:34:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                     for (l = 0; l < v.size(); l++) {
                                 ~~^~~~~~~~~~
skyscraper.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&N,&L);
     ~~~~~^~~~~~~~~~~~~~~
skyscraper.cpp:16:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (i = 0; i < N; i++) scanf("%d",&A[i]);
                             ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 568 KB Output is correct
4 Correct 4 ms 640 KB Output is correct
5 Correct 40 ms 8100 KB Output is correct
6 Correct 51 ms 8100 KB Output is correct
7 Correct 10 ms 8100 KB Output is correct
8 Correct 7 ms 8100 KB Output is correct
9 Correct 33 ms 8100 KB Output is correct
10 Correct 7 ms 8100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 108 ms 14068 KB Output is correct
2 Correct 908 ms 92276 KB Output is correct
3 Correct 400 ms 92276 KB Output is correct
4 Correct 829 ms 92276 KB Output is correct
5 Correct 670 ms 95944 KB Output is correct
6 Correct 726 ms 95944 KB Output is correct
7 Correct 331 ms 95944 KB Output is correct
8 Correct 434 ms 95944 KB Output is correct
9 Correct 643 ms 95944 KB Output is correct
10 Correct 678 ms 95944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 568 KB Output is correct
4 Correct 4 ms 640 KB Output is correct
5 Correct 40 ms 8100 KB Output is correct
6 Correct 51 ms 8100 KB Output is correct
7 Correct 10 ms 8100 KB Output is correct
8 Correct 7 ms 8100 KB Output is correct
9 Correct 33 ms 8100 KB Output is correct
10 Correct 7 ms 8100 KB Output is correct
11 Correct 108 ms 14068 KB Output is correct
12 Correct 908 ms 92276 KB Output is correct
13 Correct 400 ms 92276 KB Output is correct
14 Correct 829 ms 92276 KB Output is correct
15 Correct 670 ms 95944 KB Output is correct
16 Correct 726 ms 95944 KB Output is correct
17 Correct 331 ms 95944 KB Output is correct
18 Correct 434 ms 95944 KB Output is correct
19 Correct 643 ms 95944 KB Output is correct
20 Correct 678 ms 95944 KB Output is correct
21 Runtime error 6 ms 95944 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Halted 0 ms 0 KB -