QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#734274#9574. Stripsorz_zWA 18ms3844kbC++143.8kb2024-11-11 08:23:402024-11-11 08:23:41

Judging History

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

  • [2024-11-11 08:23:41]
  • 评测
  • 测评结果:WA
  • 用时:18ms
  • 内存:3844kb
  • [2024-11-11 08:23:40]
  • 提交

answer

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
//#pragma GCC optimize("Ofast,fast-math")
//#pragma GCC target("avx,avx2")
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef double db;
#define F(i, a, b) for(int i = a; i <= (b); ++i)
#define F2(i, a, b) for(int i = a; i < (b); ++i)
#define dF(i, a, b) for(int i = a; i >= (b); --i)
template<typename T> void debug(string s, T x) {
	cerr << "[" << s << "] = [" << x << "]\n";
}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {
	for (int i = 0, b = 0; i < (int)s.size(); i++) if (s[i] == '(' || s[i] == '{') b++;
	else if (s[i] == ')' || s[i] == '}') b--;
	else if (s[i] == ',' && b == 0) {
		cerr << "[" << s.substr(0, i) << "] = [" << x << "] | ";
		debug(s.substr(s.find_first_not_of(' ', i + 1)), args...);
		break;
	}
}
#ifdef ONLINE_JUDGE
#define Debug(...)
#else
#define Debug(...) debug(#__VA_ARGS__, __VA_ARGS__)
#endif
#define pb push_back
#define fi first
#define se second
#define Mry fprintf(stderr, "%.3lf MB\n", (&Med - &Mbe) / 1048576.0)
#define Try cerr << 1e3 * clock() / CLOCKS_PER_SEC << " ms\n";
typedef long long ll;
// namespace Fread {const int SIZE = 1 << 17; char buf[SIZE], *S, *T; inline char getchar() {if (S == T) {T = (S = buf) + fread(buf, 1, SIZE, stdin); if (S == T) return '\n';} return *S++;}}
// namespace Fwrite {const int SIZE = 1 << 17; char buf[SIZE], *S = buf, *T = buf + SIZE; inline void flush() {fwrite(buf, 1, S - buf, stdout), S = buf;} inline void putchar(char c) {*S++ = c;if (S == T) flush();} struct NTR {~NTR() {flush();}} ztr;}
// #ifdef ONLINE_JUDGE
// #define getchar Fread::getchar
// #define putchar Fwrite::putchar
// #endif
inline int ri() {
	int x = 0;
	bool t = 0;
	char c = getchar();
	while (c < '0' || c > '9') t |= c == '-', c = getchar();
	while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
	return t ? -x : x;
}
inline void wi(int x) {
	if (x < 0) {
		putchar('-'), x = -x;
	}
	if (x > 9) wi(x / 10);
	putchar(x % 10 + 48);
}
inline void wi(int x, char s) {
	wi(x), putchar(s);
}
bool Mbe;
// mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3f;
const int _ = 2e5 + 5;

int n, m, k, w;

int a[_], b[_];

void solve() {
	n = ri(), m = ri(), k = ri(), w = ri();
	F(i, 1, n) a[i] = ri();
	F(i, 1, m) b[i] = ri();
	sort(a + 1, a + n + 1);
	sort(b + 1, b + m + 1);
	b[0] = 0, b[m + 1] = w + 1;
	vector<pii> A;
	F(i, 1, m + 1) if(b[i] > b[i - 1] + 1) {
		A.pb(make_pair(b[i - 1] + 1, b[i] - 1));
	}
	for(pii v : A) if(v.se - v.fi + 1 < k) {
		int l = lower_bound(a + 1, a + n + 1, v.fi) - a;
		int r = upper_bound(a + 1, a + n + 1, v.se) - a - 1;
		if(l <= r) {
			puts("-1");
			return;
		}
	}
//	Debug("114");
	vi ans;
	for(pii v : A) {
		Debug(v.fi, v.se);
		int l = lower_bound(a + 1, a + n + 1, v.fi) - a;
		int r = upper_bound(a + 1, a + n + 1, v.se) - a - 1;
		if(l > r) continue;
		int lst = v.fi - 1;
		F(j, l, r) {
			int p = upper_bound(a + 1, a + n + 1, a[j] + k - 1) - a - 1;
			Debug(p, a[p], max(lst + 1, a[p] - k + 1));
			if(max(lst + 1, a[p] - k + 1) + k - 1 > v.se) {
				puts("-1");
				return;
			}
			Debug(l, r, j, p);
			ans.pb(max(lst + 1, a[p] - k + 1));
			lst = max(lst + 1, a[p] - k + 1) + k - 1;
			j = p;
		}
	}
	cout << ans.size() << '\n';
	for(int v : ans) cout << v << ' ';
	cout <<'\n';
}
bool Med;
signed main() {
	// Mry;
	int T = ri();
	while(T--) solve();
	// Try;
	return 0;
}

/*
24 196055605
ginganjingnanjingnanjing
*/

详细

Test #1:

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

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: 18ms
memory: 3556kb

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 36 40 
3
22 46 64 
8
1 7 20 24 30 36 54 63 
3
3 14 30 
6
1 7 11 30 41 47 
4
14 27 34 47 
2
42 65 
1
27 
1
9 
1
62 
5
24 33 42 47 60 
2
3 31 
3
11 19 29 
3
2 15 33 
3
25 30 42 
3
2 17 59 
4
1 11 21 32 
2
53 65 
3
49 58 65 
3
43 60 78 
1
78 
4
1 11 15 21 
5
3 7 17 36 48 
2
1 44 ...

result:

wrong answer Participant didn't find a solution but the jury found one. (test case 48)