QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#803219 | #9574. Strips | Hiraethsoul# | WA | 25ms | 3892kb | C++23 | 1.8kb | 2024-12-07 16:28:17 | 2024-12-07 16:28:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
void solve()
{
i64 n, m, k, w;
cin >> n >> m >> k >> w;
vector<pair<i64, i64>> a(n + m + 2, {0, 0});
for (int i = 1; i <= n; ++i)
{
cin >> a[i].first;
a[i].second = 1;
}
for (int i = 1; i <= m; ++i)
{
cin >> a[i + n].first;
}
a[n + m + 1] = {1e18, 0};
sort(a.begin(), a.end());
i64 posl = 1, posr = 0, l = 0, r = 0;
vector<i64> dp(n + m + 1, 0), pre(n + m + 1, -1);
vector<i64> ans;
vector<bool> alive(n + m + 1, 1);
bool ok = 1;
for (int i = 1; i <= n + m + 1; ++i)
{
if (a[i].second)
{
continue;
}
alive[i] = 0;
r = a[i].first;
posr = i - 1;
dp[posl - 1] = a[posl - 1].first;
i64 L = posl - 1, R = posl - 1;
for (int j = posl; j <= posr; ++j)
{
i64 t = a[j].first - k + 1;
while (L < R and (a[L + 1].first < t or !alive[L + 1]))
{
L++;
}
dp[j] = max(dp[L] + k, a[j].first);
pre[j] = L;
alive[j] = dp[j - 1] < a[j].first;
R++;
}
if (dp[posr] >= r)
{
cout << -1 << '\n';
return;
}
int cur = posr;
while (~pre[cur])
{
ans.push_back(cur);
cur = pre[cur];
}
posl = i + 1;
}
cout << ans.size() << '\n';
for (auto id : ans)
{
cout << dp[id] - k + 1 << ' ';
}
cout << '\n';
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--)
{
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
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 9 6 14 -1 2 1 4 -1
result:
ok ok 4 cases (4 test cases)
Test #2:
score: -100
Wrong Answer
time: 25ms
memory: 3892kb
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 4 3 14 22 40 36 28 3 22 46 64 8 7 1 24 20 30 36 54 63 3 3 14 30 6 30 11 7 1 47 41 4 14 34 27 47 2 65 42 1 27 1 9 1 62 5 24 42 33 60 47 2 3 31 3 19 11 29 3 2 15 33 3 30 25 42 3 2 17 59 4 21 11 1 32 2 65 53 3 49 58 65 3 60 43 78 1 78 4 1 11 21 15 5 3 7 36 17 48 2 1 44 ...
result:
wrong answer Integer parameter [name=l_i] equals to 81, violates the range [1, 80] (test case 464)