Submission #946093

#TimeUsernameProblemLanguageResultExecution timeMemory
946093hariaakas646Skyscraper (JOI16_skyscraper)C++17
20 / 100
930 ms186020 KiB
#include <bits/stdc++.h> using namespace std; #define scd(t) scanf("%d", &t) #define sclld(t) scanf("%lld", &t) #define forr(i, l, r) for(int i=l; i<r; i++) #define frange(i, l) forr(i, 0, l) #define pb push_back #define mp make_pair #define f first #define s second #define all(x) x.begin(), x.end() typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pii> vii; typedef long long lli; typedef vector<vi> vvi; typedef vector<lli> vll; typedef vector<bool> vb; typedef set<int> seti; typedef multiset<int> mseti; void usaco() { freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin); // freopen("problem.out", "w", stdout); } const lli mod = 1e9 + 7; int main() { // usaco(); int n; scd(n); int l; scd(l); vector<vector<vll>> dp(1<<n, vector<vll>(n, vll(l+1, 0))); vi vec(n); frange(i, n) { scd(vec[i]); } frange(i, n) { dp[1<<i][i][0] = 1; } forr(i, 1, 1<<n) { frange(j, n) { frange(k, l+1) { if(dp[i][j][k]) continue; frange(e, n) { if(e != j && (i & (1<<e))) { int d = abs(vec[e] - vec[j]); if(k >= d) { dp[i][j][k] += dp[i^(1<<j)][e][k-d]; dp[i][j][k] %= mod; } } } } } } lli tot = 0; frange(j, n) { frange(k, l+1) { tot += dp[(1<<n)-1][j][k]; tot %= mod; } } printf("%lld\n", tot); }

Compilation message (stderr)

skyscraper.cpp: In function 'void usaco()':
skyscraper.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
skyscraper.cpp: In function 'int main()':
skyscraper.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
skyscraper.cpp:36:5: note: in expansion of macro 'scd'
   36 |     scd(n);
      |     ^~~
skyscraper.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
skyscraper.cpp:38:5: note: in expansion of macro 'scd'
   38 |     scd(l);
      |     ^~~
skyscraper.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
skyscraper.cpp:43:9: note: in expansion of macro 'scd'
   43 |         scd(vec[i]);
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...