QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#729101 | #9574. Strips | ucup-team3160# | WA | 1ms | 5924kb | C++14 | 2.0kb | 2024-11-09 16:29:41 | 2024-11-09 16:29:42 |
Judging History
answer
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include "lib.h"
#endif
#define rep(i, min, max) for(int i = (min); i <= (max); ++i)
#define nrep(i, max, min) for(int i = (max); i >= (min); --i)
#define reads(str) (scanf("%s", str + 1), strlen(str + 1))
#define case() int Ts = read(); rep(T, 1, Ts)
#define putf(flag) puts((flag) ? "Yes" : "No")
#define put(x) printf("%d ", x)
#define putl(x) printf("%lld ", x)
#define endl() putchar('\n')
using namespace std;
typedef long long ll;
inline int read()
{
int now=0; bool nev=false; char c=getchar();
while(c<'0' || c>'9') { if(c=='-') nev=true; c=getchar(); }
while(c>='0' && c<='9') { now=(now<<1)+(now<<3)+(c&15); c=getchar(); }
return nev?-now:now;
}
const int N = 1e6 + 10;
int a[N], b[N];
vector<pair<int, int>> vec;
vector<int> ans;
int main() {
case() {
int n = read(), m = read(), k = read(), w = read();
vec = {}; ans = {};
rep(i, 1, n) a[i] = read(), vec.push_back({a[i], 1});
rep(i, 1, m) b[i] = read(), vec.push_back({b[i], 0});
vec.push_back({w + 1, 0});
int lastl = 0, lastr = w + 2, fl = 1, need = 0;
sort(vec.begin(), vec.end());
for(auto [x, op] : vec) {
// print(x, op, lastl, lastr);
if(op == 0) {
if(need) {
if(x - 1 - lastl < k) { fl = 0; break; }
ans.push_back(lastl + 1);
need = 0;
}
lastl = x;
} else {
if(!need) {
need = 1;
lastr = x - 1;
}
if(x <= lastr + k) { lastl = max(x - k, lastl); continue; }
ans.push_back(lastl);
lastl = lastl + k;
lastr = x - 1;
}
}
if(!fl) { puts("-1"); continue; }
put(ans.size()), endl();
for(int i : ans) put(i); endl();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5924kb
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 10 14 -1 2 1 4 -1
result:
wrong answer There is no stripe covering red cell 9 (test case 1)