Submission #1232355

#TimeUsernameProblemLanguageResultExecution timeMemory
1232355hainam2k9Magneti (COCI21_magneti)C++20
0 / 110
21 ms5696 KiB
#include <bits/stdc++.h> #define tt cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0) #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout) #define ll long long #define ull unsigned long long #define i128 __int128 #define db long double #define sz(a) ((int)(a).size()) #define pb emplace_back #define pf emplace_front #define pob pop_back #define pof pop_front #define lb lower_bound #define ub upper_bound #define fi first #define se second #define ins emplace #define mp make_pair using namespace std; const int MOD = 1e9+7, MAXN = 1e4+5; const string NAME = ""; int n,l,a[55],dp[55][55][MAXN],rs=0; void add(int& a, int b){ a+=b; if(a>=MOD) a-=MOD; } int modpow(int a, int b){ if(b==0) return 1; ll half=modpow(a,b>>1); half=(half*half)%MOD; if(b&1) return (half*a)%MOD; return half; } int main() { tt; if(fopen((NAME + ".INP").c_str(), "r")) fo; cin >> n >> l; for(int i = 1; i<=n; ++i) cin >> a[i]; sort(a+1,a+n+1); dp[0][0][0]=1; for(int i = 0; i<n; ++i) for(int j = 0; j<=i; ++j) for(int k = 0; k<l; ++k){ if(dp[i][j][k]==0) continue; add(dp[i+1][j+1][k],1ll*(j+1)*dp[i][j][k]%MOD); if(j>=1&&k+a[i+1]<l) add(dp[i+1][j][k+a[i+1]],2ll*j*dp[i][j][k]%MOD); if(j>=2&&k+2*a[i+1]<l) add(dp[i+1][j-1][k+2*a[i+1]],dp[i][j][k]); } for(int i = 0; i<l; ++i) add(rs,1ll*dp[n][1][i]*modpow(l-i,n)%MOD); cout << rs; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:3:19: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:37:45: note: in expansion of macro 'fo'
   37 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
Main.cpp:3:63: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |                                                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:37:45: note: in expansion of macro 'fo'
   37 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...