QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#511370 | #5451. 树据结构 | Franuch# | 20 | 928ms | 110412kb | C++17 | 2.6kb | 2024-08-09 19:52:20 | 2024-08-09 19:52:22 |
Judging History
answer
#include "ds.h"
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
#define st first
#define nd second
struct Pair {
ll v, mx;
};
vector<pair<ll, ll>> s;
vector<ll> rec(vector<Pair> a, ll l, ll max) {
if (a.size() == 1) {
if (l != max) {
exchange(l, max);
s.emplace_back(l, max);
}
return {a[0].v};
}
exchange(l, max);
s.emplace_back(l, max);
for (auto &[v, mx] : a) {
mx = query(v + 1);
}
sort(a.begin(), a.end(), [](auto &v, auto &w) {
return v.mx < w.mx;
});
vector<ll> ret;
ret.push_back(a[0].v);
vector<vector<Pair>> b = {{a[1]}};
for (ll i = 2; i < a.size(); i++) {
if (b.back()[0].mx == a[i].mx)
b.back().push_back(a[i]);
else {
b.emplace_back();
b.back().push_back(a[i]);
}
}
l++;
for (auto & part : b) {
vector<ll> tmp = rec(part, l, part[0].mx);
for (ll v: tmp)
ret.push_back(v);
l += (ll) part.size();
}
return ret;
}
void dlasciezki(ll n) {
vector<Pair> a(n);
for (ll v = 1; v < n; v++) {
a[v].v = v;
a[v].mx = query(v + 1);
}
sort(a.begin(), a.end(), [](auto &v, auto &w) {
return v.mx < w.mx;
});
vector<ll> ret = {0};
vector<vector<Pair>> b = {{a[1]}};
for (ll i = 2; i < a.size(); i++) {
if (b.back()[0].mx == a[i].mx)
b.back().push_back(a[i]);
else {
b.emplace_back();
b.back().push_back(a[i]);
}
}
ll l = 1;
for (auto & part : b) {
vector<ll> tmp = rec(part, l, part[0].mx);
for (ll v: tmp)
ret.push_back(v);
l += (ll) part.size();
}
vector<ll> ord(n - 1);
std::iota(ord.begin(), ord.end(), 1);
vector<ll> pos(n);
std::iota(pos.begin(), pos.end(), -1);
while (not s.empty()) {
auto p = s.back();
swap(pos[p.st], pos[p.nd]);
swap(ord[pos[p.st]], ord[pos[p.nd]]);
s.pop_back();
}
vector<ll> vord(n);
for (ll i = 0; i < n; i++)
vord[ret[i]] = i;
vector<ll> parent(n - 1), val(n - 1);
for (ll i = 1; i < n; i++) {
parent[i - 1] = ret[vord[i] - 1] + 1;
val[i - 1] = ord[vord[i] - 1];
}
answer(parent, val);
}
void solve(ll n, ll lim1, ll lim2) {
if (n == 1) {
answer(vector<ll>(), vector<ll>());
return;
}
ll subtask = lim1 % 10;
if (subtask == 1 or subtask == 3 or subtask == 6) {
dlasciezki(n);
}
}
詳細信息
Subtask #1:
score: 6
Accepted
Test #1:
score: 6
Accepted
time: 0ms
memory: 32464kb
input:
sfdjklasl2335n1j;llksaet35GTwejtklwrklakrjlt 50 1000001 1000001 2351tgsaldjkgakldfjtkjl;3136sajdflkjasdf135bbbwq 28 2 18 36 14 34 37 5 44 1 21 29 46 16 43 31 33 30 23 50 17 8 26 41 3 24 40 11 35 10 27 45 39 13 42 19 4 47 7 49 32 48 15 6 20 22 12 38 25 3 36 9 26 32 4 43 29 47 31 14 11 27 39 49 5 8 42...
output:
6640196347516987400
result:
ok single line: '6640196347516987400'
Test #2:
score: 6
Accepted
time: 0ms
memory: 32728kb
input:
sfdjklasl2335n1j;llksaet35GTwejtklwrklakrjlt 50 1000001 1000001 2351tgsaldjkgakldfjtkjl;3136sajdflkjasdf135bbbwq 44 41 43 3 28 37 32 36 16 6 23 4 2 13 5 45 26 30 22 50 7 33 15 17 20 42 39 38 47 14 31 1 27 21 11 8 49 19 24 18 35 10 9 29 12 25 46 34 48 1 3 36 27 15 19 39 16 5 12 33 28 32 9 7 37 29 11 ...
output:
9195104755648076998
result:
ok single line: '9195104755648076998'
Test #3:
score: 6
Accepted
time: 0ms
memory: 34536kb
input:
sfdjklasl2335n1j;llksaet35GTwejtklwrklakrjlt 50 1000001 1000001 2351tgsaldjkgakldfjtkjl;3136sajdflkjasdf135bbbwq 31 7 50 35 36 38 23 21 28 4 2 19 11 32 45 14 47 6 30 27 26 22 9 5 16 20 1 41 48 42 29 18 15 12 17 46 49 24 34 8 33 37 10 25 13 43 3 44 39 36 1 13 38 26 44 22 28 41 3 24 23 25 45 17 42 37 ...
output:
12239100023551140712
result:
ok single line: '12239100023551140712'
Test #4:
score: 6
Accepted
time: 5ms
memory: 32492kb
input:
sfdjklasl2335n1j;llksaet35GTwejtklwrklakrjlt 50 1000001 1000001 2351tgsaldjkgakldfjtkjl;3136sajdflkjasdf135bbbwq 42 44 36 4 19 25 16 41 38 37 17 39 27 3 5 33 13 34 24 8 15 50 45 43 21 11 47 28 26 30 23 6 48 20 14 9 18 40 46 7 49 10 2 22 29 1 31 32 12 37 6 10 44 43 42 8 4 38 15 9 48 12 26 35 31 27 46...
output:
14494350283792382446
result:
ok single line: '14494350283792382446'
Test #5:
score: 6
Accepted
time: 0ms
memory: 32488kb
input:
sfdjklasl2335n1j;llksaet35GTwejtklwrklakrjlt 50 1000001 1000001 2351tgsaldjkgakldfjtkjl;3136sajdflkjasdf135bbbwq 18 8 42 34 41 43 2 20 30 15 21 45 17 29 1 5 48 16 44 26 14 32 10 12 40 4 33 22 9 49 24 27 46 50 6 11 7 36 38 28 47 35 31 23 25 37 19 3 13 26 47 49 46 9 23 5 42 35 37 31 11 10 38 4 18 45 1...
output:
4462608412883436222
result:
ok single line: '4462608412883436222'
Subtask #2:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #6:
score: 0
Wrong Answer
time: 3ms
memory: 32624kb
input:
sfdjklasl2335n1j;llksaet35GTwejtklwrklakrjlt 1000 1100002 2200002 2351tgsaldjkgakldfjtkjl;3136sajdflkjasdf135bbbwq 619 804 82 356 408 877 20 754 750 1000 584 529 754 501 589 653 359 643 653 855 601 287 448 53 145 479 693 151 754 274 261 46 347 362 431 721 289 893 754 203 976 206 754 58 551 967 754 6...
output:
result:
wrong answer 1st lines differ - expected: '7269721258820694274', found: ''
Subtask #3:
score: 14
Accepted
Dependency #1:
100%
Accepted
Test #11:
score: 14
Accepted
time: 190ms
memory: 53276kb
input:
sfdjklasl2335n1j;llksaet35GTwejtklwrklakrjlt 100000 3000003 3000003 2351tgsaldjkgakldfjtkjl;3136sajdflkjasdf135bbbwq 33827 33123 16694 34094 71288 81667 48390 39245 82618 91807 17432 97045 21453 82461 61723 90007 16117 70765 93244 85769 54977 36918 22087 99387 88251 7593 13647 3087 74182 39589 89432...
output:
13911087176570347776
result:
ok single line: '13911087176570347776'
Test #12:
score: 14
Accepted
time: 204ms
memory: 52908kb
input:
sfdjklasl2335n1j;llksaet35GTwejtklwrklakrjlt 100000 3000003 3000003 2351tgsaldjkgakldfjtkjl;3136sajdflkjasdf135bbbwq 18132 96819 4888 19118 61063 8216 74382 43346 75767 26957 79573 94152 54129 45707 71102 69506 8461 20628 48443 68471 13821 27728 30935 99166 99169 81574 32977 47676 96808 57378 82388 ...
output:
15329642941023629260
result:
ok single line: '15329642941023629260'
Test #13:
score: 14
Accepted
time: 187ms
memory: 52612kb
input:
sfdjklasl2335n1j;llksaet35GTwejtklwrklakrjlt 100000 3000003 3000003 2351tgsaldjkgakldfjtkjl;3136sajdflkjasdf135bbbwq 65942 56974 33336 83232 82510 79931 80979 55182 64464 58370 99316 49841 56993 92754 56332 84857 3031 87809 37116 93092 14744 30446 42360 27308 26688 31340 86070 75832 46795 37242 1394...
output:
17969492568206842748
result:
ok single line: '17969492568206842748'
Test #14:
score: 14
Accepted
time: 227ms
memory: 50592kb
input:
sfdjklasl2335n1j;llksaet35GTwejtklwrklakrjlt 100000 3000003 3000003 2351tgsaldjkgakldfjtkjl;3136sajdflkjasdf135bbbwq 22927 31086 80416 69932 53151 4981 73728 37725 93260 80751 75939 16927 54560 15805 62642 91628 20774 28987 81328 10183 38231 45283 34431 9391 81489 15308 6744 29394 89142 9177 61468 4...
output:
8606904430482983974
result:
ok single line: '8606904430482983974'
Test #15:
score: 14
Accepted
time: 171ms
memory: 50792kb
input:
sfdjklasl2335n1j;llksaet35GTwejtklwrklakrjlt 100000 3000003 3000003 2351tgsaldjkgakldfjtkjl;3136sajdflkjasdf135bbbwq 32255 8751 93362 62560 24833 50648 86023 30267 62565 68871 94883 65360 59516 26919 33992 53547 55506 70571 78365 65635 65192 34778 69386 29059 61486 81560 61653 79052 39699 91166 5714...
output:
10853853962941559604
result:
ok single line: '10853853962941559604'
Subtask #4:
score: 0
Wrong Answer
Test #16:
score: 0
Wrong Answer
time: 5ms
memory: 34948kb
input:
sfdjklasl2335n1j;llksaet35GTwejtklwrklakrjlt 20000 3000004 3000004 2351tgsaldjkgakldfjtkjl;3136sajdflkjasdf135bbbwq 4879 6169 1969 17706 4213 18093 4963 18252 19119 2557 12571 19437 17865 6637 7288 13247 12644 15689 13894 5948 4474 12271 18580 6962 20000 8024 17921 15238 125 4044 14282 297 2126 1468...
output:
result:
wrong answer 1st lines differ - expected: '11411519532273973792', found: ''
Subtask #5:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%
Subtask #6:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Dependency #3:
100%
Accepted
Test #26:
score: 0
Wrong Answer
time: 928ms
memory: 110412kb
input:
sfdjklasl2335n1j;llksaet35GTwejtklwrklakrjlt 500000 3500006 3500006 2351tgsaldjkgakldfjtkjl;3136sajdflkjasdf135bbbwq 460684 50662 402759 348828 39765 243335 264918 486782 349512 6488 307879 428164 316732 93952 179037 37692 398136 359968 237375 197968 479670 246003 258655 130159 380414 339706 342955 ...
output:
result:
wrong answer 1st lines differ - expected: '11685763537789029324', found: ''
Subtask #7:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%