답안 #961605

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
961605 2024-04-12T08:48:27 Z Unforgettablepl Skyscraper (JOI16_skyscraper) C++17
15 / 100
410 ms 181740 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

const int modulo = 1e9+7;

int DP[16384][101][14];

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,l;
    cin >> n >> l;
    vector<int> arr(n);
    for(int&i:arr)cin>>i;
    for(int bitmask=0;bitmask<(1<<n);bitmask++){
        for(int currlen=0;currlen<=l;currlen++){
            for(int last=0;last<n;last++){
                if((bitmask&(1<<last))==0)continue;
                if(bitmask==(1<<last)){DP[bitmask][currlen][last]=1;continue;}
                int lastmask = bitmask^(1<<last);
                for(int bit=0;bit<n;bit++){
                    if(lastmask&(1<<bit)){
                        if(abs(arr[last]-arr[bit])<=currlen)DP[bitmask][currlen][last]+=DP[lastmask][currlen-abs(arr[last]-arr[bit])][bit];
                    }
                }
            }
        }
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        ans+=DP[(1<<n)-1][l][i];
        ans%=modulo;
    }
    cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Incorrect 15 ms 4736 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 47700 KB Output is correct
2 Correct 410 ms 181512 KB Output is correct
3 Correct 190 ms 181584 KB Output is correct
4 Correct 401 ms 181672 KB Output is correct
5 Correct 379 ms 181740 KB Output is correct
6 Correct 357 ms 181584 KB Output is correct
7 Correct 168 ms 181412 KB Output is correct
8 Correct 190 ms 181468 KB Output is correct
9 Correct 266 ms 181620 KB Output is correct
10 Correct 336 ms 181520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Incorrect 15 ms 4736 KB Output isn't correct
6 Halted 0 ms 0 KB -