QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#731428#9574. Stripsucup-team1766#WA 0ms3664kbC++231.4kb2024-11-10 03:53:252024-11-10 03:53:25

Judging History

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

  • [2024-11-10 03:53:25]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3664kb
  • [2024-11-10 03:53:25]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

void run() {
	int n, m, k, w; cin >> n >> m >> k >> w;
	vector<pair<int,bool>> a;
	while (n--) {
		int x; cin >> x; x--;
		a.emplace_back(x, 0);
	}
	while (m--) {
		int x; cin >> x; x--;
		a.emplace_back(x, 1);
	}
	ranges::sort(a);
	a.emplace_back(w, 1);

	int ans = 0, last = -1;
	vector<array<int,3>> st {{0, 0, 0}}; // x, left, run
	for (auto [x, t] : a) {
		if (not t) {
			if (x >= st.back()[0] + k*st.back()[2]) {
				ans++;
				st.push_back({x, x - max(last, st.back()[0] + k*st.back()[2]), 1});
				while (st.size() > 2 and st[st.size()-2][0] + k*st[st.size()-2][2] == st.back()[0]) {
					st[st.size()-2][2] += st.back()[2];
					st.pop_back();
				}
			}
		} else {
			for (int total = st.back()[0] + k*st.back()[2] - x; total > 0;) {
				int move = min(st.back()[0] + k*st.back()[2] - x, st.back()[1]);
				st.back()[1] -= move;
				total -= move;
				
				while (st.size() > 2 and st[st.size()-2][0] + k*st[st.size()-2][2] == st.back()[0]) {
					st[st.size()-2][2] += st.back()[2];
					st.pop_back();
				}

				if (st.size() == 2 and not st.back()[1]) {
					cout << "-1\n";
					return;
				}
			}
			last = x+1;
		}
	}

	cout << ans << '\n';
	for (unsigned i = 1; i < st.size(); i++) {
		for (int j = 0; j < st[i][2]; j++) {
			cout << st[i][0] + j*k + 1 << ' ';
		}
	}
	cout << '\n';
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	int t; cin >> t; while (t--) run();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3664kb

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)