(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #316361

#TimeUsernameProblemLanguageResultExecution timeMemory
316361BeanZKangaroo (CEOI16_kangaroo)C++14
100 / 100
65 ms31740 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 if (i > cs) dp[i][j] = (dp[i][j] + dp[i - 1][j + 1] * (j + 1)) % mod; // ghep 1 nhom loai 1 va mot nhom loai 3 if (i > cf) dp[i][j] = (dp[i][j] + dp[i - 1][j + 1] * (j + 1)) % mod; } //cout << dp[i][j] << " "; } //cout << endl; } cout << dp[n - 1][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...