# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
332633 | 2020-12-03T01:55:27 Z | daniel920712 | Skyscraper (JOI16_skyscraper) | C++14 | 1199 ms | 251500 KB |
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <algorithm> #include <vector> #include <queue> using namespace std; bool have[16390][20][105]={0}; long long DP[16390][20][105]={0}; long long MOD=1e9+7; long long all[20]; long long N,M; long long F(long long x,long long y,long long z) { long long i; //printf("%lld %lld\n",N,M); if(z>M) return 0; if(x==0) return 1; if(have[x][y][z]) return DP[x][y][z]; have[x][y][z]=1; for(i=0;i<N;i++) { if(x&(1<<i)) { //printf("%lld %lld %lld\n",i,y,abs(all[i]-all[y])); DP[x][y][z]+=F(x-(1<<i),i,z+(long long) abs(all[i]-all[y])); DP[x][y][z]%=MOD; } } //printf("%lld %lld %lld %lld\n",x,y,z,DP[x][y][z]); return DP[x][y][z]; } int main() { long long i,ans=0; scanf("%lld %lld",&N,&M); for(i=0;i<N;i++) scanf("%lld",&all[i]); for(i=0;i<N;i++) { ans+=F(((1<<N)-1)-(1<<i),i,0); ans%=MOD; } printf("%lld\n",ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 876 KB | Output is correct |
5 | Correct | 2 ms | 2796 KB | Output is correct |
6 | Correct | 2 ms | 2668 KB | Output is correct |
7 | Correct | 2 ms | 2156 KB | Output is correct |
8 | Correct | 3 ms | 2924 KB | Output is correct |
9 | Incorrect | 3 ms | 3052 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 133 ms | 55660 KB | Output is correct |
2 | Correct | 219 ms | 215404 KB | Output is correct |
3 | Correct | 862 ms | 248300 KB | Output is correct |
4 | Correct | 200 ms | 205560 KB | Output is correct |
5 | Correct | 158 ms | 180716 KB | Output is correct |
6 | Correct | 809 ms | 251500 KB | Output is correct |
7 | Correct | 178 ms | 197100 KB | Output is correct |
8 | Correct | 805 ms | 248520 KB | Output is correct |
9 | Correct | 1199 ms | 249836 KB | Output is correct |
10 | Correct | 212 ms | 210028 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 876 KB | Output is correct |
5 | Correct | 2 ms | 2796 KB | Output is correct |
6 | Correct | 2 ms | 2668 KB | Output is correct |
7 | Correct | 2 ms | 2156 KB | Output is correct |
8 | Correct | 3 ms | 2924 KB | Output is correct |
9 | Incorrect | 3 ms | 3052 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |