QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#128627 | #4794. Salaj | training4usaco | WA | 1ms | 3492kb | C++17 | 1.5kb | 2023-07-21 14:02:34 | 2023-07-21 14:02:36 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 55;
int n, m, mod;
int dp[MAXN][MAXN];
int pref[MAXN][MAXN];
void solve() {
cin >> n >> m >> mod;
for(int i = 0; i <= n; ++i) {
for(int j = 0; j <= n; ++j) {
dp[i][j] = pref[i][j] = 0;
}
}
dp[0][1] = 1;
for(int j = 1; j <= n; ++j) {
for(int i = n - 1; i >= 0; --i) {
pref[i][j] = (pref[i + 1][j] + dp[i][j]) % mod;
}
}
for(int i = 1; i <= m; ++i) {
for(int j = n - 1; j >= 0; --j) {
for(int k = n; k >= j + 1; --k) {
if(i <= j * (j - 1) / 2 + (k - j) * (k - 1) + (n - k) * (n - k - 1) / 2) {
if(j) dp[j][k] = dp[j - 1][k - 1];
else dp[j][k] = 0;
if(k == n) dp[j][k] += dp[j][n];
dp[j][k] += pref[j + 1][k];
dp[j][k] %= mod;
}
else {
dp[j][k] = 0;
}
}
}
for(int k = 1; k <= n; ++k) {
for(int j = n - 1; j >= 0; --j) {
pref[j][k] = pref[j + 1][k] + dp[j][k];
pref[j][k] %= mod;
}
}
int ans = 0;
for(int j = 1; j <= n; ++j) {
ans += pref[0][j]; ans %= mod;
}
cout << ans << " ";
}
cout << endl;
}
signed main() {
cin.tie(0)->sync_with_stdio(false);
int t; cin >> t;
while(t--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3492kb
input:
2 5 10 666013 6 9 10
output:
1 2 4 10 30 65 70 28 0 0 1 2 4 9 2 5 5 4 2
result:
wrong answer 4th numbers differ - expected: '9', found: '10'