QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#807593 | #9870. Items | ucup-team5008 | WA | 33ms | 4088kb | C++23 | 2.3kb | 2024-12-10 08:46:30 | 2024-12-10 08:46:31 |
Judging History
answer
#include <cstdio>
#include <bitset>
const int N = 100005;
const int LG = 17;
std::bitset<N * 2> b, lg[LG], dp, next;
int t, n;
long long m;
std::bitset<N * 2> shift(std::bitset<N * 2> bt, int delta) {
if (delta >= 0) return bt << delta;
else return bt >> -delta;
}
int main() {
scanf("%d", &t);
while (t--) {
scanf("%d%lld", &n, &m);
b.reset();
for (int i = 0; i < n; ++i) {
int w;
scanf("%d", &w);
b.set(w);
}
long long mid = m / n;
lg[0] = b;
lg[0] <<= n - mid;
int j;
for (j = 0;;) {
if (1 << j + 1 <= n) {
long long mid1 = (m << j + 1) / n;
lg[j + 1].reset();
//printf("mid for %d is %lld\n", 1 << j + 1, mid1);
for (int i = n - (n >> j); i < n + (n >> j); ++i) {
if (lg[j].test(i)) {
//lg[j + 1] |= (lg[j] << i) >> -(-mid1 + 2 * mid - n);
lg[j + 1] |= shift(lg[j], i - mid1 + 2 * mid - n);
}
}
mid = mid1;
++j;
} else break;
}
mid = 0;
int restored = 0;
dp.reset();
dp.set(n);
while (j >= 0) {
if (n >> j & 1) {
next.reset();
long long mid_dp = (m << j) / n;
restored |= 1 << j;
long long mid_next = (m * restored) / n;
for (int i = n - (n >> j); i < n + (n >> j); ++i) {
if (lg[j].test(i)) {
next |= shift(dp, i - mid_next + mid + mid_dp - n);
for (int k = 0; k < 2 * n; ++k) if (dp.test(k)) {
int ind = i + k - mid_next + mid + mid_dp - n;
if (ind >= 0 && ind < 2 * n) {
next.set(ind);
}
}
}
}
std::swap(dp, next);
mid = mid_next;
}
--j;
}
if (dp.test(m + n - mid)) printf("Yes\n");
else printf("No\n");
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 4088kb
input:
4 5 25 0 0 0 0 5 5 11 4 4 4 5 5 5 0 1 2 3 4 5 5 25 0 1 2 3 4
output:
Yes No No No
result:
ok 4 token(s): yes count is 1, no count is 3
Test #2:
score: -100
Wrong Answer
time: 33ms
memory: 4064kb
input:
1314 1 0 0 1 0 1 1 1 0 1 1 1 2 0 0 0 2 0 0 1 2 0 0 2 2 0 1 0 2 0 1 1 2 0 1 2 2 0 2 0 2 0 2 1 2 0 2 2 2 1 0 0 2 1 0 1 2 1 0 2 2 1 1 0 2 1 1 1 2 1 1 2 2 1 2 0 2 1 2 1 2 1 2 2 2 2 0 0 2 2 0 1 2 2 0 2 2 2 1 0 2 2 1 1 2 2 1 2 2 2 2 0 2 2 2 1 2 2 2 2 2 3 0 0 2 3 0 1 2 3 0 2 2 3 1 0 2 3 1 1 2 3 1 2 2 3 2 0...
output:
Yes No No Yes Yes Yes Yes Yes No No Yes No No No Yes No Yes No No No No No No Yes Yes Yes Yes Yes Yes Yes No No No No No No Yes No Yes No No No Yes No No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No No No Yes No No No Yes No No No Yes Yes Yes...
result:
wrong answer expected YES, found NO [245th token]