QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#732205 | #9574. Strips | Lzy_# | WA | 0ms | 3548kb | C++14 | 1.7kb | 2024-11-10 13:39:41 | 2024-11-10 13:39:42 |
Judging History
answer
#include <bits/stdc++.h>
void solve() {
int n, m, k, w;
std::cin >> n >> m >> k >> w;
std::vector<int> a(n + 1);
for (int i = 1; i <= n; ++ i) {
std::cin >> a[i];
}
std::vector<int> b(m + 3);
b[1] = 0, b[m + 2] = w + 1;
for (int i = 2; i <= m + 1; ++ i) {
std::cin >> b[i];
}
std::sort(a.begin(), a.end());
std::sort(b.begin(), b.end());
int cur = 0;
std::vector<int> ans;
for (int i = 1; i <= m + 1; ++ i) {
int l = b[i], r = b[i + 1];
std::vector<int> g;
while (cur < n && a[cur + 1] > l && a[cur + 1] < r) {
cur ++;
g.push_back(a[cur]);
}
if (!g.size()) {
continue;
}
std::vector<int> f;
int lmin = r, pos = -1;
for (int j = g.size() - 1; j >= 0; -- j) {
if (g[j] >= lmin) {
continue;
} else {
if (g[j] - l < k) {
pos = j;
break;
}
lmin = g[j] - k + 1;
f.push_back(lmin);
}
}
if (pos == -1) {
for (auto j : f) {
ans.push_back(j - k + 1);
}
} else {
ans.push_back(l + 1);
int rmax = l + k;
if (rmax >= r) {
std::cout << -1 << '\n';
return ;
}
reverse(f.begin(), f.end());
for (auto j : f) {
if (j <= rmax) {
ans.push_back(rmax + 1);
rmax = rmax + k;
if (rmax >= r) {
std::cout << -1 << '\n';
return ;
}
} else {
ans.push_back(j);
}
}
}
}
std::cout << ans.size() << '\n';
for (auto i : ans) {
std::cout << i << ' ';
}
std::cout << '\n';
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0); std::cout.tie(0);
int T;
std::cin >> T;
while (T --) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3548kb
input:
4 5 2 3 16 7 11 2 9 14 13 5 3 2 4 11 6 10 2 1 11 2 1 2 6 1 5 3 2 1 2 6 1 5 2
output:
4 1 6 9 14 -1 2 1 3 -1
result:
wrong answer There is at least one stripe covering black cell 3 (test case 3)