QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#729671 | #9574. Strips | ucup-team4074# | WA | 23ms | 5668kb | C++17 | 1.9kb | 2024-11-09 17:35:56 | 2024-11-09 17:35:59 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;
void solve();
signed main() {
fast
int t = 1;
cin >> t;
while (t--) solve();
}
const int N = 2e5 + 10;
using pii = pair<int, int>;
#define red 1
#define black 0
int n, m, k, w;
int a[N], b[N];
vector<pii> cells;
void solve() {
cin >> n >> m >> k >> w;
cells.clear();
for(int i = 1; i <= n; i++) cin >> a[i], cells.emplace_back(a[i], red);
for(int i = 1; i <= m; i++) cin >> b[i], cells.emplace_back(b[i], black);
cells.emplace_back(0, black);
cells.emplace_back(w + 1, black);
sort(cells.begin(), cells.end());
vector<int> res;
for(int i = 1; i < cells.size() - 1; i++){
if(cells[i].second == black) continue;
int lb = cells[i - 1].first;
int j = i;
while(cells[j + 1].second == red) j++;
int rb = cells[j + 1].first;
vector<int> strips;
int last_cover_pos = -1;
for(int t = i; t <= j; t++){
if(last_cover_pos < cells[t].first){
strips.emplace_back(cells[t].first);
last_cover_pos = cells[t].first + k - 1;
}
}
if(strips.size() > (rb - lb - 1) / k){
cout << -1 << '\n';
return;
}
if(last_cover_pos < rb){
res.insert(res.end(), strips.begin(), strips.end());
continue;
}
for(int t = 0; t < strips.size(); t++){
if(strips[t] + (strips.size() - t) * k - 1 < rb) continue;
int pos = rb - (int)(strips.size() - t) * k;
while(t < strips.size()) strips[t] = pos, t++, pos += k;
}
res.insert(res.end(), strips.begin(), strips.end());
i = j;
}
cout << res.size() << '\n';
for(int ls : res){
cout << ls << ' ';
}
cout << '\n';
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5668kb
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 10 14 -1 2 1 5 -1
result:
ok ok 4 cases (4 test cases)
Test #2:
score: -100
Wrong Answer
time: 23ms
memory: 5596kb
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 3 32 33 11 3 4 4 14 22 28 36 40 36 40 40 3 32 48 66 10 3 9 9 22 26 26 31 38 54 65 -1 12 1 8 12 31 8 12 31 12 31 31 41 47 -1 4 52 67 67 75 5 27 28 29 30 31 -1 1 62 10 24 33 43 34 43 43 48 60 60 61 3 4 31 32 4 11 20 20 31 3 3 16 33 4 25 30 30 42 4 3 17 18 60 4 1 11 21 33 3 54 66 66 4...
result:
wrong answer There are more than one stripe covering cell 33 (test case 1)