QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#135952 | #6400. Game: Celeste | kyEEcccccc | WA | 178ms | 18944kb | C++14 | 2.3kb | 2023-08-06 16:22:44 | 2023-08-06 16:22:48 |
Judging History
answer
// Author: kyEEcccccc
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define F(i, l, r) for (int i = (l); i <= (r); ++i)
#define FF(i, r, l) for (int i = (r); i >= (l); --i)
#define MAX(a, b) ((a) = max(a, b))
#define MIN(a, b) ((a) = min(a, b))
#define SZ(a) ((int)((a).size()) - 1)
constexpr int N = 1000005;
constexpr ULL B = 10086001;
ULL pwb[N];
struct SegTreeNode
{
ULL x;
int ls, rs;
};
SegTreeNode tr[N * 21];
int tot_nd;
int add(int p, int cl, int cr, int pos, int x)
{
int pp = ++tot_nd;
tr[pp] = tr[p];
if (cl == cr) return tr[pp].x += x, pp;
int cm = (cl + cr) >> 1;
if (pos <= cm) tr[pp].ls = add(tr[p].ls, cl, cm, pos, x);
else tr[pp].rs = add(tr[p].rs, cm + 1, cr, pos, x);
tr[pp].x = tr[tr[pp].ls].x * pwb[cr - cm] + tr[tr[pp].rs].x;
return pp;
}
bool cmp(int u, int v, int cl, int cr)
{
if (cl == cr) return tr[u].x < tr[v].x;
int cm = (cl + cr) >> 1;
if (tr[tr[u].rs].x == tr[tr[v].rs].x) return cmp(tr[u].ls, tr[v].ls, cl, cm);
else return cmp(tr[u].rs, tr[v].rs, cm + 1, cr);
}
vector<int> ans;
void print(int p, int cl, int cr)
{
if (cl == cr)
{
// F(i, 1, tr[p].x) cout << cl << ' ';
F(i, 1, tr[p].x) ans.push_back(cl);
return;
}
int cm = (cl + cr) >> 1;
print(tr[p].rs, cm + 1, cr);
print(tr[p].ls, cl, cm);
}
int n, dl, dr, a[N], b[N];
int rt[N];
void work(void)
{
cin >> n >> dl >> dr;
F(i, 1, n) cin >> a[i];
F(i, 1, n) cin >> b[i];
deque<int> deq{1};
tot_nd = 0;
rt[1] = add(0, 1, n, b[1], 1);
int p = 1;
F(i, 2, n)
{
while (a[i] - a[p] >= dl)
{
while (!deq.empty() && !cmp(rt[p], rt[deq.back()], 1, n)) deq.pop_back();
deq.push_back(p);
++p;
}
while (!deq.empty() && a[i] - a[deq.front()] > dr) deq.pop_front();
if (deq.empty() || rt[deq.front()] == 0) rt[i] = 0;
else rt[i] = add(rt[deq.front()], 1, n, b[i], 1);
}
if (rt[n] == 0) cout << "-1\n";
else
{
ans.clear();
print(rt[n], 1, n);
cout << ans.size() << '\n';
for (auto x : ans) cout << x << ' ';
cout << '\n';
}
}
signed main(void)
{
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
ios::sync_with_stdio(0), cin.tie(nullptr);
pwb[0] = 1;
F(i, 1, 1000000) pwb[i] = pwb[i - 1] * B;
int _; cin >> _;
while (_--) work();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 4ms
memory: 17796kb
input:
2 5 2 3 1 2 3 4 5 5 2 3 1 4 3 1 2 1 4 7 3 3 3
output:
3 5 4 3 -1
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 178ms
memory: 18944kb
input:
10000 57 8 11 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 11 16 7 7 10 13 9 14 10 1 12 4 8 13 3 20 16 7 16 19 20 8 19 7 16 6 17 13 7 19 17 11 12 17 6 3 7 8 14 2 4 15 5 18 16 7 20 9 1...
output:
8 20 20 19 16 14 12 11 3 28 20 19 16 16 15 15 14 13 13 12 12 11 11 8 8 7 7 6 6 5 5 4 4 4 4 4 2 1 6 6 5 3 2 1 1 10 19 18 18 17 17 11 10 9 7 7 185 20 20 20 20 20 20 20 20 19 19 19 19 19 19 19 19 19 19 19 19 18 18 18 18 18 17 17 17 17 17 17 17 17 16 16 16 16 16 16 16 16 15 15 15 15 15 15 15 15 15 1...
result:
wrong answer 1st lines differ - expected: '7', found: '8'