QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#730078#9574. Stripsucup-team3215#WA 28ms3832kbC++231.6kb2024-11-09 18:34:552024-11-09 18:35:00

Judging History

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

  • [2024-11-09 18:35:00]
  • 评测
  • 测评结果:WA
  • 用时:28ms
  • 内存:3832kb
  • [2024-11-09 18:34:55]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

vector<int> solve(vector<int> a, int n, int k) {
  if (a.empty()) return {};
  map<int, int> from;
  int x = 1, l = max(a[0], k - 1), r = a[0] + k, ll = l + k, rr = l + k;
  for (int i = 1; i < a.size(); ++i) {
    if (a[i] < l) continue;
    from[a[i] + k] = l;
    if (a[i] < r) {
      l = a[i];
      rr = a[i] + k;
    } else if (a[i] < ll) {
      l = ll;
      r = a[i] + k;
      ll = rr = l + k;
    } else {
      l = a[i];
      ll = rr = r = a[i] + k;
    }
  }
  if (n <= l) return {-1};
  vector<int> res;
  int last = l;
  while (1) {
    res.push_back(last - k + 1);
    if (last == max(a[0], k - 1)) break;
    last = from.upper_bound(last)->second;
  }
  reverse(res.begin(), res.end());
  return res;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  for (int tc = (cin >> tc, tc); tc--; ) {
    int n, m, k, w; cin >> n >> m >> k >> w;
    vector<int> a(n), b(m);
    for (auto& a: a) cin >> a;
    for (auto& b: b) cin >> b;
    sort(a.begin(), a.end());
    b.push_back(0);
    b.push_back(w + 1);
    sort(b.begin(), b.end());
    vector<int> ans;
    bool fail = 0;
    for (int i = 1, j = 0; i < m + 2; ++i) {
      vector<int> ta;
      while (j < n && a[j] < b[i]) ta.push_back(a[j++] - b[i - 1] - 1);
      auto cans = solve(move(ta), b[i] - b[i - 1] - 1, k);
      for (auto cans: cans) fail |= !~cans, ans.push_back(cans + b[i - 1] + 1);
    }
    if (fail) { cout << "-1\n"; continue; }
    cout << ans.size() << '\n';
    for (auto ans: ans) cout << ans << ' '; cout << '\n';
  }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3832kb

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 4 
-1

result:

ok ok 4 cases (4 test cases)

Test #2:

score: -100
Wrong Answer
time: 28ms
memory: 3672kb

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:

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

result:

wrong answer There are more than one stripe covering cell 32 (test case 1)