QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#732205#9574. StripsLzy_#WA 0ms3548kbC++141.7kb2024-11-10 13:39:412024-11-10 13:39:42

Judging History

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

  • [2024-11-10 13:39:42]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3548kb
  • [2024-11-10 13:39:41]
  • 提交

answer

#include <bits/stdc++.h>

void solve() {
	int n, m, k, w;
	std::cin >> n >> m >> k >> w;
	
	std::vector<int> a(n + 1);
	for (int i = 1; i <= n; ++ i) {
		std::cin >> a[i];
	}
	std::vector<int> b(m + 3);
	b[1] = 0, b[m + 2] = w + 1; 
	for (int i = 2; i <= m + 1; ++ i) {
		std::cin >> b[i];
	}
	
	std::sort(a.begin(), a.end());
	std::sort(b.begin(), b.end());
	
	int cur = 0;
	std::vector<int> ans;
	for (int i = 1; i <= m + 1; ++ i) {
		int l = b[i], r = b[i + 1];
		std::vector<int> g;
		while (cur < n && a[cur + 1] > l && a[cur + 1] < r) {
			cur ++;
			g.push_back(a[cur]);
		}
		if (!g.size()) {
			continue;
		}
		std::vector<int> f;
		int lmin = r, pos = -1;
		for (int j = g.size() - 1; j >= 0; -- j) {
			if (g[j] >= lmin) {
				continue;
			} else {
				if (g[j] - l < k) {
					pos = j;
					break;
				}
				lmin = g[j] - k + 1;
				f.push_back(lmin);
			}
		}
		if (pos == -1) {
			for (auto j : f) {
				ans.push_back(j - k + 1);
			}
		} else {
			ans.push_back(l + 1);
			int rmax = l + k;
			if (rmax >= r) {
				std::cout << -1 << '\n';
				return ;
			}
			reverse(f.begin(), f.end());
			for (auto j : f) {
				if (j <= rmax) {
					ans.push_back(rmax + 1);
					rmax = rmax + k;
					if (rmax >= r) {
						std::cout << -1 << '\n';
						return ;
					}
				} else {
					ans.push_back(j);
				}
			}
		}
	}
	
	std::cout << ans.size() << '\n';
	for (auto i : ans) {
		std::cout << i << ' ';
	}
	std::cout << '\n';
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0);

    int T;
    std::cin >> T;

    while (T --) {
    	solve();
    }

    return 0;
}

详细

Test #1:

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

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

result:

wrong answer There is at least one stripe covering black cell 3 (test case 3)