QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#179963 | #7244. Elvis Presley | mendicillin2# | AC ✓ | 1ms | 3868kb | C++17 | 1.5kb | 2023-09-15 13:59:18 | 2023-09-15 13:59:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
template <class T> int sz(T&& a) { return int(size(forward<T>(a))); }
template <class T> using vc = vector<T>;
template <class T> using vvc = vc<vc<T>>;
using ll = int64_t;
using vi = vc<int>;
template <class F>
struct ycr {
F f;
template <class T>
explicit ycr(T&& f_) : f(forward<T>(f_)) {}
template <class... Args>
decltype(auto) operator()(Args&&... args) {
return f(ref(*this), forward<Args>(args)...);
}
};
template <class F>
decltype(auto) yc(F&& f) {
return ycr<decay_t<F>>(forward<F>(f));
}
int main() {
ios_base::sync_with_stdio(false), cin.tie(nullptr);
cout << fixed << setprecision(20);
int a, b; cin >> a >> b;
auto parent = [&](int i) -> int {
assert(i > 1);
return i/2;
};
auto depth = [&](int i) -> int {
int d = 0;
while (i > 1) {
i = parent(i);
d++;
}
return d;
};
set<int> ans({a, b});
auto join_other_ch = [&](int i) -> void {
assert(i >= 1);
ans.insert(i^1);
};
if (depth(a) > depth(b)) swap(a, b);
while (depth(a) < depth(b)) {
join_other_ch(b);
b = parent(b);
}
if (a == b) {
cout << -1 << '\n';
exit(0);
}
while (a != b) {
if ((a^1) != b) {
join_other_ch(a);
join_other_ch(b);
}
a = parent(a);
b = parent(b);
assert(depth(a) == depth(b));
}
//cerr << "lca=" << a << endl;
while (a > 1) {
if (a == 1) break;
join_other_ch(a);
a = parent(a);
}
vector<int> out;
for (int i : ans) out.push_back(i);
int n = int(out.size());
//cout << n << '\n';
for (int i = 0; i < n; i++) {
cout << out[i] << " \n"[i+1==n];
}
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
input:
2 7
output:
2 6 7
result:
ok 3 number(s): "2 6 7"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
1 2
output:
-1
result:
ok 1 number(s): "-1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
7 2
output:
2 6 7
result:
ok 3 number(s): "2 6 7"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
2 1
output:
-1
result:
ok 1 number(s): "-1"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
2 3
output:
2 3
result:
ok 2 number(s): "2 3"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
3 2
output:
2 3
result:
ok 2 number(s): "2 3"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
1 3
output:
-1
result:
ok 1 number(s): "-1"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
3 1
output:
-1
result:
ok 1 number(s): "-1"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
1 536870912
output:
-1
result:
ok 1 number(s): "-1"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
536870912 1
output:
-1
result:
ok 1 number(s): "-1"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
1 1000000000
output:
-1
result:
ok 1 number(s): "-1"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
1000000000 1
output:
-1
result:
ok 1 number(s): "-1"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
3 536870912
output:
3 5 9 17 33 65 129 257 513 1025 2049 4097 8193 16385 32769 65537 131073 262145 524289 1048577 2097153 4194305 8388609 16777217 33554433 67108865 134217729 268435457 536870912 536870913
result:
ok 30 numbers
Test #14:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
536870912 3
output:
3 5 9 17 33 65 129 257 513 1025 2049 4097 8193 16385 32769 65537 131073 262145 524289 1048577 2097153 4194305 8388609 16777217 33554433 67108865 134217729 268435457 536870912 536870913
result:
ok 30 numbers
Test #15:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
3 1000000000
output:
-1
result:
ok 1 number(s): "-1"
Test #16:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
1000000000 3
output:
-1
result:
ok 1 number(s): "-1"
Test #17:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
3 805306368
output:
-1
result:
ok 1 number(s): "-1"
Test #18:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
805306368 3
output:
-1
result:
ok 1 number(s): "-1"
Test #19:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
3 805306367
output:
3 4 10 22 46 94 190 382 766 1534 3070 6142 12286 24574 49150 98302 196606 393214 786430 1572862 3145726 6291454 12582910 25165822 50331646 100663294 201326590 402653182 805306366 805306367
result:
ok 30 numbers
Test #20:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
805306367 3
output:
3 4 10 22 46 94 190 382 766 1534 3070 6142 12286 24574 49150 98302 196606 393214 786430 1572862 3145726 6291454 12582910 25165822 50331646 100663294 201326590 402653182 805306366 805306367
result:
ok 30 numbers
Test #21:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
2 536870912
output:
-1
result:
ok 1 number(s): "-1"
Test #22:
score: 0
Accepted
time: 1ms
memory: 3568kb
input:
536870912 2
output:
-1
result:
ok 1 number(s): "-1"
Test #23:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
2 1000000000
output:
2 6 15 28 58 118 239 477 952 1906 3815 7628 15259 30516 61034 122071 244141 488280 976563 1953124 3906251 7812501 15625001 31250001 62500001 125000001 250000001 500000001 1000000000 1000000001
result:
ok 30 numbers
Test #24:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
1000000000 2
output:
2 6 15 28 58 118 239 477 952 1906 3815 7628 15259 30516 61034 122071 244141 488280 976563 1953124 3906251 7812501 15625001 31250001 62500001 125000001 250000001 500000001 1000000000 1000000001
result:
ok 30 numbers
Test #25:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
2 805306368
output:
2 7 13 25 49 97 193 385 769 1537 3073 6145 12289 24577 49153 98305 196609 393217 786433 1572865 3145729 6291457 12582913 25165825 50331649 100663297 201326593 402653185 805306368 805306369
result:
ok 30 numbers
Test #26:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
805306368 2
output:
2 7 13 25 49 97 193 385 769 1537 3073 6145 12289 24577 49153 98305 196609 393217 786433 1572865 3145729 6291457 12582913 25165825 50331649 100663297 201326593 402653185 805306368 805306369
result:
ok 30 numbers
Test #27:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
2 805306367
output:
-1
result:
ok 1 number(s): "-1"
Test #28:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
805306367 2
output:
-1
result:
ok 1 number(s): "-1"
Test #29:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
42424242 42424243
output:
3 4 11 21 41 81 160 322 646 1295 2588 5179 10356 20715 41428 82858 165718 331438 662879 1325756 2651514 5303031 10606061 21212120 42424242 42424243
result:
ok 26 numbers
Test #30:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
42424243 42424242
output:
3 4 11 21 41 81 160 322 646 1295 2588 5179 10356 20715 41428 82858 165718 331438 662879 1325756 2651514 5303031 10606061 21212120 42424242 42424243
result:
ok 26 numbers
Test #31:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
42424243 42424244
output:
3 4 11 21 41 81 160 322 646 1295 2588 5179 10356 20715 41428 82858 165718 331438 662879 1325756 2651514 5303031 21212120 21212123 42424242 42424243 42424244 42424245
result:
ok 28 numbers
Test #32:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
42424244 42424243
output:
3 4 11 21 41 81 160 322 646 1295 2588 5179 10356 20715 41428 82858 165718 331438 662879 1325756 2651514 5303031 21212120 21212123 42424242 42424243 42424244 42424245
result:
ok 28 numbers
Test #33:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
45126748 42184716
output:
3 4 11 41 42 81 87 161 173 320 345 642 689 1286 1376 2575 2755 5148 5509 10298 11016 20599 22035 41197 44068 82393 88139 164785 176277 329569 352553 659137 705104 1318273 1410211 2636545 2820420 5273088 5640842 10546178 11281686 21092359 22563375 42184716 42184717 45126748 45126749
result:
ok 47 numbers
Test #34:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
42184716 45126748
output:
3 4 11 41 42 81 87 161 173 320 345 642 689 1286 1376 2575 2755 5148 5509 10298 11016 20599 22035 41197 44068 82393 88139 164785 176277 329569 352553 659137 705104 1318273 1410211 2636545 2820420 5273088 5640842 10546178 11281686 21092359 22563375 42184716 42184717 45126748 45126749
result:
ok 47 numbers
Test #35:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
10491481 97935359
output:
3 4 21 22 41 47 81 92 161 187 321 372 641 746 1281 1495 2560 2989 5123 5976 10244 11955 20490 23908 40983 47818 81965 95638 163928 191278 327859 382558 655716 765118 1311434 1530238 2622871 3060478 5245741 6120958 10491480 10491481 12241918 24483838 48967678 97935358 97935359
result:
ok 47 numbers
Test #36:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
97935359 10491481
output:
3 4 21 22 41 47 81 92 161 187 321 372 641 746 1281 1495 2560 2989 5123 5976 10244 11955 20490 23908 40983 47818 81965 95638 163928 191278 327859 382558 655716 765118 1311434 1530238 2622871 3060478 5245741 6120958 10491480 10491481 12241918 24483838 48967678 97935358 97935359
result:
ok 47 numbers
Test #37:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
536732 549613992
output:
-1
result:
ok 1 number(s): "-1"
Test #38:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
549613992 536732
output:
-1
result:
ok 1 number(s): "-1"
Test #39:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
1 4
output:
-1
result:
ok 1 number(s): "-1"
Test #40:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
4 1
output:
-1
result:
ok 1 number(s): "-1"
Test #41:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
2 4
output:
-1
result:
ok 1 number(s): "-1"
Test #42:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
4 2
output:
-1
result:
ok 1 number(s): "-1"
Test #43:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
3 4
output:
3 4 5
result:
ok 3 number(s): "3 4 5"
Test #44:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
4 3
output:
3 4 5
result:
ok 3 number(s): "3 4 5"
Test #45:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
1 5
output:
-1
result:
ok 1 number(s): "-1"
Test #46:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
5 1
output:
-1
result:
ok 1 number(s): "-1"
Test #47:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
2 5
output:
-1
result:
ok 1 number(s): "-1"
Test #48:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
5 2
output:
-1
result:
ok 1 number(s): "-1"
Test #49:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
3 5
output:
3 4 5
result:
ok 3 number(s): "3 4 5"
Test #50:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
5 3
output:
3 4 5
result:
ok 3 number(s): "3 4 5"
Test #51:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
4 5
output:
3 4 5
result:
ok 3 number(s): "3 4 5"
Test #52:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
5 4
output:
3 4 5
result:
ok 3 number(s): "3 4 5"
Test #53:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
1 6
output:
-1
result:
ok 1 number(s): "-1"
Test #54:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
6 1
output:
-1
result:
ok 1 number(s): "-1"
Test #55:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
2 6
output:
2 6 7
result:
ok 3 number(s): "2 6 7"
Test #56:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
6 2
output:
2 6 7
result:
ok 3 number(s): "2 6 7"
Test #57:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
3 6
output:
-1
result:
ok 1 number(s): "-1"
Test #58:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
6 3
output:
-1
result:
ok 1 number(s): "-1"
Test #59:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
4 6
output:
4 5 6 7
result:
ok 4 number(s): "4 5 6 7"
Test #60:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
6 4
output:
4 5 6 7
result:
ok 4 number(s): "4 5 6 7"
Test #61:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
5 6
output:
4 5 6 7
result:
ok 4 number(s): "4 5 6 7"
Test #62:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
6 5
output:
4 5 6 7
result:
ok 4 number(s): "4 5 6 7"
Test #63:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
1 7
output:
-1
result:
ok 1 number(s): "-1"
Test #64:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
7 1
output:
-1
result:
ok 1 number(s): "-1"
Test #65:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
3 7
output:
-1
result:
ok 1 number(s): "-1"
Test #66:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
7 3
output:
-1
result:
ok 1 number(s): "-1"
Test #67:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
4 7
output:
4 5 6 7
result:
ok 4 number(s): "4 5 6 7"
Test #68:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
7 4
output:
4 5 6 7
result:
ok 4 number(s): "4 5 6 7"
Test #69:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
5 7
output:
4 5 6 7
result:
ok 4 number(s): "4 5 6 7"
Test #70:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
7 5
output:
4 5 6 7
result:
ok 4 number(s): "4 5 6 7"
Test #71:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
6 7
output:
2 6 7
result:
ok 3 number(s): "2 6 7"
Test #72:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
7 6
output:
2 6 7
result:
ok 3 number(s): "2 6 7"
Test #73:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
1024 1023
output:
5 6 9 14 17 30 33 62 65 126 129 254 257 510 513 1022 1023 1024 1025
result:
ok 19 numbers
Test #74:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
1023 1024
output:
5 6 9 14 17 30 33 62 65 126 129 254 257 510 513 1022 1023 1024 1025
result:
ok 19 numbers
Test #75:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
536870912 536870911
output:
5 6 9 14 17 30 33 62 65 126 129 254 257 510 513 1022 1025 2046 2049 4094 4097 8190 8193 16382 16385 32766 32769 65534 65537 131070 131073 262142 262145 524286 524289 1048574 1048577 2097150 2097153 4194302 4194305 8388606 8388609 16777214 16777217 33554430 33554433 67108862 67108865 134217726 134217...
result:
ok 57 numbers
Test #76:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
536870911 536870912
output:
5 6 9 14 17 30 33 62 65 126 129 254 257 510 513 1022 1025 2046 2049 4094 4097 8190 8193 16382 16385 32766 32769 65534 65537 131070 131073 262142 262145 524286 524289 1048574 1048577 2097150 2097153 4194302 4194305 8388606 8388609 16777214 16777217 33554430 33554433 67108862 67108865 134217726 134217...
result:
ok 57 numbers
Test #77:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
1000000000 999999999
output:
2 6 15 28 58 118 239 477 952 1906 3815 7628 15259 30516 61034 122071 244141 488280 976563 3906248 3906251 7812498 7812501 15624998 15625001 31249998 31250001 62499998 62500001 124999998 125000001 249999998 250000001 499999998 500000001 999999998 999999999 1000000000 1000000001
result:
ok 39 numbers
Test #78:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
999999999 1000000000
output:
2 6 15 28 58 118 239 477 952 1906 3815 7628 15259 30516 61034 122071 244141 488280 976563 3906248 3906251 7812498 7812501 15624998 15625001 31249998 31250001 62499998 62500001 124999998 125000001 249999998 250000001 499999998 500000001 999999998 999999999 1000000000 1000000001
result:
ok 39 numbers
Extra Test:
score: 0
Extra Test Passed