QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#728411 | #9574. Strips | ucup-team3931# | WA | 0ms | 3828kb | C++14 | 1.3kb | 2024-11-09 15:07:28 | 2024-11-09 15:07:28 |
Judging History
answer
#include <bits/stdc++.h>
#define pb emplace_back
#define fst first
#define scd second
#define mkp make_pair
#define uint unsigned
#define mems(a, x) memset((a), (x), sizeof(a))
using namespace std;
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;
typedef pair<ll, ll> pii;
const int maxn = 1000100;
ll n, m, K, W;
pii a[maxn];
void solve() {
scanf("%lld%lld%lld%lld", &n, &m, &K, &W);
for (int i = 1; i <= n; ++i) {
scanf("%lld", &a[i].fst);
a[i].scd = 0;
}
for (int i = 1; i <= m; ++i) {
scanf("%lld", &a[i + n].fst);
a[i + n].scd = 1;
}
int tot = n + m;
a[++tot] = mkp(0, 1);
a[++tot] = mkp(W + 1, 1);
sort(a + 1, a + tot + 1);
int j = -1;
vector<int> ans;
for (int i = 1; i <= tot; ++i) {
if (a[i].scd) {
if (j == -1) {
j = i;
continue;
}
ll cnt = 0, r = 0;
for (int k = j + 1; k < i; ++k) {
if (r < a[k].fst) {
r = a[k].fst + K - 1;
ans.pb(a[k].fst);
++cnt;
}
}
if (cnt * K > a[i].fst - a[j].fst - 1) {
puts("-1");
return;
}
j = i;
}
}
printf("%d\n", (int)ans.size());
for (int i = 0; i < (int)ans.size(); ++i) {
printf("%d%c", ans[i], " \n"[i == (int)ans.size() - 1]);
}
}
int main() {
int T = 1;
scanf("%d", &T);
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3828kb
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 2 7 11 14 -1 2 1 5 -1
result:
wrong answer There is at least one stripe covering black cell 13 (test case 1)