# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
365425 | 2021-02-11T16:24:02 Z | BartolM | Skyscraper (JOI16_skyscraper) | C++17 | 926 ms | 94700 KB |
#include <bits/stdc++.h> using namespace std; #define X first #define Y second #define mp make_pair #define pb push_back typedef long long ll; typedef pair <int, int> pii; typedef pair <int, pii> pip; typedef pair <pii, int> ppi; typedef pair <ll, ll> pll; const int INF=0x3f3f3f3f; const int N=14; const int MOD=1e9+7; int n, m; int p[N]; int dp[(1<<14)+2][N][105]; int add(int a, int b) { return (a+b)%MOD; } int rek(int mask, int pr, int br) { if (br>m) return 0; if (__builtin_popcount(mask)==n) return 1; int &ret=dp[mask][pr][br]; if (ret!=-1) return ret; ret=0; for (int i=0; i<n; ++i) { if (mask & (1<<i)) continue; ret=add(ret, rek(mask | (1<<i), i, br+abs(p[i]-p[pr]))); } return ret; } void load() { scanf("%d %d", &n, &m); for (int i=0; i<n; ++i) scanf("%d", &p[i]); } int main() { load(); assert(n<=14); memset(dp, -1, sizeof dp); int sol=0; for (int i=0; i<n; ++i) sol=add(sol, rek((1<<i), i, 0)); printf("%d\n", sol); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 94572 KB | Output is correct |
2 | Correct | 52 ms | 94592 KB | Output is correct |
3 | Correct | 50 ms | 94572 KB | Output is correct |
4 | Correct | 50 ms | 94572 KB | Output is correct |
5 | Correct | 50 ms | 94572 KB | Output is correct |
6 | Correct | 50 ms | 94572 KB | Output is correct |
7 | Correct | 50 ms | 94572 KB | Output is correct |
8 | Correct | 57 ms | 94548 KB | Output is correct |
9 | Incorrect | 51 ms | 94572 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 122 ms | 94572 KB | Output is correct |
2 | Correct | 97 ms | 94572 KB | Output is correct |
3 | Correct | 657 ms | 94700 KB | Output is correct |
4 | Correct | 94 ms | 94572 KB | Output is correct |
5 | Correct | 73 ms | 94700 KB | Output is correct |
6 | Correct | 591 ms | 94700 KB | Output is correct |
7 | Correct | 81 ms | 94572 KB | Output is correct |
8 | Correct | 596 ms | 94700 KB | Output is correct |
9 | Correct | 926 ms | 94592 KB | Output is correct |
10 | Correct | 99 ms | 94572 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 94572 KB | Output is correct |
2 | Correct | 52 ms | 94592 KB | Output is correct |
3 | Correct | 50 ms | 94572 KB | Output is correct |
4 | Correct | 50 ms | 94572 KB | Output is correct |
5 | Correct | 50 ms | 94572 KB | Output is correct |
6 | Correct | 50 ms | 94572 KB | Output is correct |
7 | Correct | 50 ms | 94572 KB | Output is correct |
8 | Correct | 57 ms | 94548 KB | Output is correct |
9 | Incorrect | 51 ms | 94572 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |