QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#729141#9574. Stripsucup-team3160#WA 14ms5808kbC++142.0kb2024-11-09 16:33:242024-11-09 16:33:26

Judging History

你现在查看的是最新测评结果

  • [2024-11-09 16:33:26]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:5808kb
  • [2024-11-09 16:33:24]
  • 提交

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; lastr = w + 2;
            } else {
                if(!need) {
                    need = 1;
                    lastr = x - 1;
                }
                if(x <= lastr + k) { lastl = max(x - k, lastl); continue; }
                ans.push_back(lastl + 1);
                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: 100
Accepted
time: 1ms
memory: 5808kb

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 7 10 14 
-1
2 
1 4 
-1

result:

ok ok 4 cases (4 test cases)

Test #2:

score: -100
Wrong Answer
time: 14ms
memory: 5768kb

input:

11000
3 8 2 53
32 3 33
35 19 38 20 1 30 10 6
7 10 1 42
3 14 4 36 28 40 22
17 20 12 41 27 7 1 19 13 9
6 6 13 78
55 76 53 32 54 58
62 45 21 4 7 61
8 7 3 68
9 26 54 31 22 3 38 65
34 16 58 47 52 29 53
5 8 4 33
33 5 30 6 15
27 12 9 28 19 2 13 10
6 1 2 48
8 12 48 1 41 31
40
7 6 7 61
20 19 30 52 49 17 40
3...

output:

2 
2 32 
7 
3 4 14 22 28 29 30 
3 
22 46 64 
8 
1 4 20 23 30 36 54 63 
3 
3 14 30 
6 
1 3 5 7 41 43 
4 
14 27 34 47 
2 
42 65 
1 
27 
1 
9 
1 
62 
5 
24 33 35 47 60 
2 
3 31 
3 
11 19 29 
3 
2 15 33 
3 
25 26 42 
3 
2 17 59 
4 
1 11 21 32 
2 
53 55 
3 
49 58 65 
3 
43 60 78 
1 
78 
4 
1 11 15 18 
5 ...

result:

wrong answer There is no stripe covering red cell 36 (test case 2)