제출 #132867

#제출 시각아이디문제언어결과실행 시간메모리
132867tushar_2658Skyscraper (JOI16_skyscraper)C++14
15 / 100
1294 ms196544 KiB
#include "bits/stdc++.h" using namespace std; const int maxn = 105; int a[maxn]; long long dp[1 << 15][15][105]; int n, m; long long mod = 1e9 + 7; int main(int argc, char const *argv[]) { // freopen("in.txt", "r", stdin); scanf("%d %d", &n, &m); for(int i=0; i<n; i++){ scanf("%d", &a[i]); } for(int i=0; i<n; i++){ dp[1 << i][i][0] = 1; } for(int mask = 0; mask < (1 << n); mask++){ for(int j=0; j<n; j++){ if((mask >> j)&1){ for(int k=0; k <= m; k++){ for(int l=0; l<n; l++){ if((mask >> l)&1){} else { if(k + abs(a[l] - a[j]) <= m){ dp[mask | (1 << l)][l][k + abs(a[l] - a[j])] =(dp[mask][j][k] + dp[mask | (1 << l)][l][k + abs(a[l] - a[j])])%mod; } } } } } } } int ans = 0; for(int i=0; i<n; i++){ for(int j=0; j<m+1; j++){ ans += dp[(1 << n)-1][i][j]; ans %= mod; } }cout << ans <<endl; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

skyscraper.cpp: In function 'int main(int, const char**)':
skyscraper.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
skyscraper.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]);
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...