(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 #316393

#TimeUsernameProblemLanguageResultExecution timeMemory
316393Killer2501Kangaroo (CEOI16_kangaroo)C++14
100 / 100
48 ms23160 KiB
#include <bits/stdc++.h> #define pb push_back #define vii vector<int> #define task "teamwork" #define pll pair<ll, ll> #define pii pair< ll, pair< ll, ll > > #define fi first #define se second using namespace std; using ll = long long; using ull = unsigned long long; const int N = 2005; const ll mod = 1e9+7; //const ll base = 200; ll m, n, k, t, T, ans, s, e, u, v, cs, cf, tong, lab[N]; ll a[N], b[N], d[N], c[N], x[N], dp[N][N]; //string s; vector<ll> kq, adj[N]; set<ll> st; void sol() { cin >> n >> cs >> cf; if(cs > cf)swap(cs, cf); dp[0][0] = 1; for(int i = 1; i < n; i ++) { for(int j = 0; j <= i; j ++) { if(i == cs || i == cf) { dp[i][j] = (dp[i][j] + dp[i-1][j+1] * (j + 1)) % mod; dp[i][j] = (dp[i][j] + dp[i-1][j]) % mod; } else { if(j)dp[i][j] = (dp[i][j] + dp[i-1][j-1] ) % mod; if(j)dp[i][j] = (dp[i][j] + dp[i-1][j+1] * j * (j + 1) % mod ) % mod; if(i > cs)dp[i][j] = (dp[i][j] + dp[i-1][j+1] * (j + 1) % mod ) % mod; if(i > cf)dp[i][j] = (dp[i][j] + dp[i-1][j+1] * (j + 1) % mod ) % mod; } } } cout << dp[n-1][0]; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(task".in", "r")) { freopen(task".in","r",stdin); freopen(task".out","w",stdout); } int ntest = 1; //cin >> ntest; while(ntest -- > 0) sol(); } /* */

Compilation message (stderr)

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