QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#98896 | #4794. Salaj | Gemini7X | WA | 11ms | 4472kb | C++14 | 1.4kb | 2023-04-20 20:40:49 | 2023-04-20 20:40:52 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
T sgn = 1;
char ch = getchar();
for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
for (x = 0; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
x *= sgn;
}
int n, m, mod;
int f[305][305], g[305][305], sg[305][305];
int qmod(int x) { return x >= mod ? x - mod : x; }
void MAIN() {
read(n); read(m); read(mod);
memset(f, 0, sizeof(f));
f[1][1] = 1;
for (int i = 1; i <= m; i++) {
if (i <= 2 * n) {
memcpy(g, f, sizeof(f));
memset(f, 0, sizeof(f));
for (int j = 1; j <= n; j++) {
for (int k = 1; k <= n; k++) {
sg[j][k] = qmod(sg[j][k - 1] + g[j][k]);
}
}
} else {
for (int k = 1; k <= n; k++) {
g[n][k] = f[n][k];
sg[n][k] = qmod(sg[n][k - 1] + g[n][k]);
}
}
for (int j = 1; j <= n; j++) {
if (j < n && i > 2 * n) continue;
for (int k = 1; k <= j; k++) {
f[j][k] = qmod(g[j - 1][k] + f[j][k]);
if (j == n) f[j][k] = qmod(g[j][k] + f[j][k]);
f[j][k] = qmod(f[j][k] + sg[j][k - 1]);
}
}
int ans = 0;
if (i <= 2 * n) {
for (int j = 1; j <= n; j++) {
for (int k = 1; k <= n; k++) {
ans = qmod(ans + f[j][k]);
}
}
} else {
for (int k = 1; k <= n; k++) {
ans = qmod(ans + f[n][k]);
}
}
printf("%d ", ans);
} puts("");
}
int main() {
int T;
read(T);
while (T--) MAIN();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4168kb
input:
2 5 10 666013 6 9 10
output:
1 2 4 9 21 50 110 209 351 546 1 2 4 9 1 1 6 0 7
result:
ok 19 numbers
Test #2:
score: -100
Wrong Answer
time: 11ms
memory: 4472kb
input:
10 31 248 8654701 13 11 331266209 33 517 52876477 26 580 675225807 48 2029 311070528 26 31 327981899 39 25 644128037 29 776 464963196 43 799 451592950 25 184 564388620
output:
1 2 4 9 21 51 127 323 835 2188 5798 15511 41835 113634 310572 853467 2356779 6536382 889882 7578514 4072343 2646977 4649285 7797829 7894657 8630011 5369867 7539674 4332126 8201689 8589675 2709364 4018535 3531401 5490003 4890382 334630 1280966 7295275 4971992 1680824 7744560 2450701 2716471 1097918 5...
result:
wrong answer 63rd numbers differ - expected: '3520418', found: '5946820'