Submission #316358

#TimeUsernameProblemLanguageResultExecution timeMemory
316358BeanZKangaroo (CEOI16_kangaroo)C++14
0 / 100
0 ms384 KiB
// I_Love_LPL #include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 105; const int mod = 1e9 + 7; ll dp[2005][2005]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("A.inp", "r")){ freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } ll n, cs, cf; cin >> n >> cs >> cf; // dp[i][j] la xet den thang thu i va dang co j nhom loai 1 dp[0][0] = 1; for (int i = 1; i <= n; i++){ for (int j = 0; j <= n; j++){ if (cs == i){ // mo mot nhom moi dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod; // ghep voi mot nhom loai 1 dp[i][j] = (dp[i][j] + dp[i - 1][j + 1] * (j + 1)) % mod; } else if (cf == i){ // mo mot nhom moi dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod; // ghep voi mot nhom loai 1 dp[i][j] = (dp[i][j] + dp[i - 1][j + 1] * (j + 1)) % mod; } else { // mo mot nhom moi if (j > 0) dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % mod; // ghep 2 nhom loai 1 voi nhau dp[i][j] = (dp[i][j] + dp[i - 1][j + 1] * (j + 1) * j) % mod; // ghep 1 nhom loai 1 va mot nhom loai 2 dp[i][j] = (dp[i][j] + dp[i - 1][j + 1] * (j + 1)) % mod; // ghep 1 nhom loai 1 va mot nhom loai 3 dp[i][j] = (dp[i][j] + dp[i - 1][j + 1] * (j + 1)) % mod; } //cout << dp[i][j] << " "; } //cout << endl; } cout << dp[n][0]; } /* */

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:13:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   13 |         freopen("test.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:14:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   14 |         freopen("test.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...