QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#645330 | #6408. Classical Counting Problem | KafuuChinocpp | Compile Error | / | / | C++14 | 2.2kb | 2024-10-16 17:48:44 | 2024-10-16 17:48:44 |
Judging History
This is the latest submission verdict.
- [2024-10-16 17:48:44]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-10-16 17:48:44]
- Submitted
answer
#include <cstdio>
#include <algorithm>
using namespace std;
const int max1 = 100;
const int mod = 998244353;
int T, n, m, v, a[max1 + 5];
int C[max1 + 5][max1 + 5];
int f[max1 * max1 + 5];
void Add ( int &x, int y )
{
x += y;
if ( x >= mod )
x -= mod;
return;
}
void Solve ( int L, int R, int val )
{
memset(f, 0, sizeof(f));
f[0] = 1;
int sum = (R - L + 1) * max1;
for ( int i = L; i <= R; i ++ )
{
int tmp = abs(a[i] - val);
for ( int j = sum; j >= tmp; j -- )
Add(f[j], f[j - tmp]);
}
for ( int i = 1; i <= max1 * max1; i ++ )
Add(f[i], f[i - 1]);
return;
}
void Work ()
{
scanf("%d%d%d", &n, &m, &v);
for ( int i = 1; i <= n; i ++ )
scanf("%d", &a[i]);
sort(a + 1, a + 1 + n);
reverse(a + 1, a + 1 + n);
int ans = 1;
int L = 1;
for ( int i = 1; i <= n; i ++ )
{
while ( a[L] - a[i] > m )
++L;
Solve(L, i - 1, a[i]);
int siz = n - v - (n - i) - 1;
Add(ans, f[m * (n - v)]);
// printf("i = %d L = %d siz = %d f = %d ans = %d\n", i, L, siz, f[m * (n - v)], ans);
if ( siz >= 0 )
Add(ans, mod - C[i - L][siz]);
}
// printf("ans = %d\n", ans);
int R = n;
for ( int i = n; i >= 1; i -- )
{
while ( a[i] - a[R] > m )
--R;
Solve(i + 1, R, a[i]);
int siz = v - (i - 1);
Add(ans, f[m * v]);
// printf("i = %d R = %d siz = %d f = %d ans = %d\n", i, R, siz, f[m * v], ans);
if ( siz >= 0 )
Add(ans, mod - C[R - i][siz]);
// printf("ans = %d\n", ans);
}
printf("%d\n", ans);
return;
}
int main ()
{
C[0][0] = 1;
for ( int i = 1; i <= max1; i ++ )
{
C[i][0] = 1;
for ( int j = 1; j <= i; j ++ )
C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
}
for ( int i = 0; i <= max1; i ++ )
for ( int j = 1; j <= max1; j ++ )
Add(C[i][j], C[i][j - 1]);
scanf("%d", &T);
while ( T -- )
Work();
return 0;
}
Details
answer.code: In function ‘void Solve(int, int, int)’: answer.code:23:5: error: ‘memset’ was not declared in this scope 23 | memset(f, 0, sizeof(f)); | ^~~~~~ answer.code:3:1: note: ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’? 2 | #include <algorithm> +++ |+#include <cstring> 3 | answer.code: In function ‘void Work()’: answer.code:39:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 39 | scanf("%d%d%d", &n, &m, &v); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~ answer.code:41:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 41 | scanf("%d", &a[i]); | ~~~~~^~~~~~~~~~~~~ answer.code: In function ‘int main()’: answer.code:103:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 103 | scanf("%d", &T); | ~~~~~^~~~~~~~~~