Submission #1187408

#TimeUsernameProblemLanguageResultExecution timeMemory
1187408CodeLakVNMagneti (COCI21_magneti)C++20
10 / 110
4 ms2628 KiB
#include <bits/stdc++.h> using namespace std; #define task "21_magneti" #define no "NO" #define yes "YES" #define F first #define S second #define vec vector #define _mp make_pair #define ii pair<int, int> #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define evoid(val) return void(std::cout << val) #define FOR(i, a, b) for(int i = (a); i <= (b); ++i) #define FOD(i, b, a) for(int i = (b); i >= (a); --i) const int MAX_L = (int)1e4 + 4; const int MOD = (int)1e9 + 7; int n, length; int radius[55]; namespace sub1 { bool valid() { FOR(i, 1, n) if (radius[i] != radius[1]) return false; return true; } int dp[55][MAX_L], pre[MAX_L]; void solve() { memset(dp, 0, sizeof(dp)); FOR(i, 1, length) dp[1][i] = 1, pre[i] = i; FOR(i, 2, n) { FOR(l, 1, length) if (l > radius[1]) dp[i][l] = pre[l - radius[1]]; FOR(l, 1, length) pre[l] = (pre[l - 1] + dp[i][l]) % MOD; } int ans = 1; FOR(i, 1, n) ans = 1LL * ans * i % MOD; int sum = 0; FOR(l, 1, length) sum = (sum + dp[n][l]) % MOD; ans = 1LL * ans * sum % MOD; cout << ans << "\n"; } } namespace sub2 { bool valid() { return n <= 10; } void solve() { } } void solve() { cin >> n >> length; FOR(i, 1, n) cin >> radius[i]; if (sub1::valid()) sub1::solve(); } int32_t main() { if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); bool multitest = 0; int numTest = 1; if (multitest) cin >> numTest; while (numTest--) { solve(); } return 0; } /* Lak lu theo dieu nhac!!!! */

Compilation message (stderr)

Main.cpp: In function 'int32_t main()':
Main.cpp:69:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:70:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   70 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...