Submission #528182

#TimeUsernameProblemLanguageResultExecution timeMemory
528182tphuc2908Skyscraper (JOI16_skyscraper)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; //#pragma GCC optimize("O3,unroll-loops") //#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #define rep(i, x, y) for(int i = x; i <= y; ++i) #define repi(i,x,y) for(int i = x; i >= y; --i) #define ci(x) int x; cin>> x #define TC(t) ci(t); while(t--) #define fi first #define se second #define pb push_back #define all(x) x.begin(), x.end() #define cii(x, y) ci(x); ci(y) #define ciii(x, y, z) ci(x); ci(y); ci(z) #define mp make_pair //#define int long long typedef long long ll; typedef vector<int> vi; const int N = 1e3 + 5; const int NN = 16 + 15; const int mod = 1e9+7; const int mod1 = 1e9 + 9; const int pi = 31; const ll inf = 1e15 + 6; const int block = 500; const int dx[4] = {-1, 0, 1, 0}; const int dy[4] = {0, -1, 0, 1}; void readfile(){ #ifdef ONLINE_JUDGE #else freopen("text.inp", "r", stdin); #endif // ONLINE_JUDGE // freopen("text.inp", "r", stdin); // freopen("template.out", "w", stdout); } int n, L; int a[N]; void inp(){ cin >> n >> L; for(int i = 1; i <= n; ++i) cin >> a[i]; sort(a + 1, a + n + 1); } int add(int x, int y){ x += y; while(x < 0) x += mod; while(x >= mod) x -= mod; return x; } int mul(int x, int y){ return (x * 1LL * y) % mod; } int f[N][N][N][3]; void process(){ f[1][1][0][0] = 1; f[1][1][0][1] = 2; f[1][1][0][2] = 1; // apply open close interval trick, // each component increase by (2 * j - t) *(a[i + 1] - a[i]) // so that for a[i + 2] - a[i + 1] can combine with a[i + 1] - a[i] at some endpoint // since we have at most 2*j place to put but minus the fixed point for(int i = 1; i < n; ++i){ int diff = a[i + 1] - a[i]; for(int j = 1; j <= i; ++j){ for(int sum = 0; sum <= L; ++sum){ for(int t = 0; t <= 2; ++t){ int val = sum + (2*j - t) * (a[i + 1] - a[i]); if(val > L) continue; if(j >= 2) // merge 2 cc f[i + 1][j - 1][val][t] = add(f[i + 1][j - 1][val][t], mul(f[i][j][sum][t], j - 1)); if(t==0){ // new cc if(sum + (j + 1) * diff) f[i + 1][j + 1][val][0] = add(f[i + 1][j + 1][val][0], mul(f[i][j][sum][t], j + 1)); // new cc but in one endpoint f[i + 1][j + 1][val][1] = add(f[i + 1][j + 1][val][1], mul(f[i][j][sum][t], 2)); // two endpoint // attach to a cc f[i + 1][j][val][0] = add(f[i + 1][j][val][0], mul(f[i][j][sum][t], 2*j)); // attach to a cc but at one endpoint f[i + 1][j][val][1] = add(f[i + 1][j][val][1], mul(f[i][j][sum][t], 2)); } else if(t==1){ // new cc f[i + 1][j + 1][val][1] = add(f[i + 1][j + 1][val][1], mul(f[i][j][sum][t], j)); // new cc but in one endpoint f[i + 1][j + 1][val][2] = add(f[i + 1][j + 1][val][2], mul(f[i][j][sum][t], 1)); // attach to a cc f[i + 1][j][val][1] = add(f[i + 1][j][val][1], mul(f[i][j][sum][t], 2*j - 1)); // attach to a cc but at one endpoint f[i + 1][j][val][2] = add(f[i + 1][j][val][2], mul(f[i][j][sum][t], 1)); } else{ if(j >= 2){ // new cc f[i + 1][j + 1][val][2] = add(f[i + 1][j + 1][val][2], mul(f[i][j][sum][t], j - 1)); // attach to a cc f[i + 1][j][val][2] = add(f[i + 1][j][val][2], mul(f[i][j][sum][t], 2*j - 2)); } } } } } } int res = 0; for(int i = 0; i <= L; ++i) res = add(res, f[n][1][i][2]); cout << res; } int main() { // readfile(); ios_base::sync_with_stdio(0); cin.tie(0); inp(); process(); return 0; }

Compilation message (stderr)

skyscraper.cpp: In function 'void readfile()':
skyscraper.cpp:33:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         freopen("text.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status