QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#197658 | #3521. Insertion Order | IsaacMoris# | AC ✓ | 10ms | 3616kb | C++14 | 937b | 2023-10-02 18:06:14 | 2023-10-02 18:06:14 |
Judging History
answer
#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 3e5 + 5, inf = 2e9;
void solve(int l, int r) {
if (l > r)return;
int m = l + r >> 1;
cout << m << " ";
solve(l, m - 1);
solve(m + 1, r);
}
void print(int m, int n) {
for (int i = 1; i <= m; i++) {
cout << i << " ";
}
solve(m + 1, n);
}
void doWork() {
int n, k;
cin >> n >> k;
for (int i = 0, h = 0; i <= n; i++) {
while ((1 << h) - 1 < i)h++;
if (h + (n - i - 1) == k - 1) {
print(n - i, n);
return;
}
}
cout << "impossible";
}
int main() {
IO
int t = 1;
// cin >> t;
for (int i = 1; i <= t; i++) {
// cout << "Case #" << i << ": ";
doWork();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3444kb
input:
7 4
output:
1 4 2 3 6 5 7
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3416kb
input:
8 3
output:
impossible
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3396kb
input:
1 1
output:
1
result:
ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3436kb
input:
2 1
output:
impossible
result:
ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3424kb
input:
2 2
output:
1 2
result:
ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
3 1
output:
impossible
result:
ok
Test #7:
score: 0
Accepted
time: 1ms
memory: 3428kb
input:
3 2
output:
2 1 3
result:
ok
Test #8:
score: 0
Accepted
time: 0ms
memory: 3440kb
input:
3 3
output:
1 2 3
result:
ok
Test #9:
score: 0
Accepted
time: 0ms
memory: 3440kb
input:
4 1
output:
impossible
result:
ok
Test #10:
score: 0
Accepted
time: 0ms
memory: 3436kb
input:
4 2
output:
impossible
result:
ok
Test #11:
score: 0
Accepted
time: 1ms
memory: 3428kb
input:
4 3
output:
1 3 2 4
result:
ok
Test #12:
score: 0
Accepted
time: 0ms
memory: 3432kb
input:
4 4
output:
1 2 3 4
result:
ok
Test #13:
score: 0
Accepted
time: 1ms
memory: 3564kb
input:
5 1
output:
impossible
result:
ok
Test #14:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
5 2
output:
impossible
result:
ok
Test #15:
score: 0
Accepted
time: 0ms
memory: 3416kb
input:
5 3
output:
3 1 2 4 5
result:
ok
Test #16:
score: 0
Accepted
time: 0ms
memory: 3396kb
input:
5 4
output:
1 2 4 3 5
result:
ok
Test #17:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
5 5
output:
1 2 3 4 5
result:
ok
Test #18:
score: 0
Accepted
time: 1ms
memory: 3436kb
input:
200000 17
output:
impossible
result:
ok
Test #19:
score: 0
Accepted
time: 10ms
memory: 3440kb
input:
200000 18
output:
100000 50000 25000 12500 6250 3125 1562 781 390 195 97 48 24 12 6 3 1 2 4 5 9 7 8 10 11 18 15 13 14 16 17 21 19 20 22 23 36 30 27 25 26 28 29 33 31 32 34 35 42 39 37 38 40 41 45 43 44 46 47 72 60 54 51 49 50 52 53 57 55 56 58 59 66 63 61 62 64 65 69 67 68 70 71 84 78 75 73 74 76 77 81 79 80 82 83 90...
result:
ok
Test #20:
score: 0
Accepted
time: 9ms
memory: 3400kb
input:
200000 200000
output:
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
ok
Test #21:
score: 0
Accepted
time: 1ms
memory: 3548kb
input:
200000 1
output:
impossible
result:
ok
Test #22:
score: 0
Accepted
time: 7ms
memory: 3436kb
input:
131070 17
output:
65535 32767 16383 8191 4095 2047 1023 511 255 127 63 31 15 7 3 1 2 5 4 6 11 9 8 10 13 12 14 23 19 17 16 18 21 20 22 27 25 24 26 29 28 30 47 39 35 33 32 34 37 36 38 43 41 40 42 45 44 46 55 51 49 48 50 53 52 54 59 57 56 58 61 60 62 95 79 71 67 65 64 66 69 68 70 75 73 72 74 77 76 78 87 83 81 80 82 85 8...
result:
ok
Test #23:
score: 0
Accepted
time: 1ms
memory: 3448kb
input:
2047 11
output:
1024 512 256 128 64 32 16 8 4 2 1 3 6 5 7 12 10 9 11 14 13 15 24 20 18 17 19 22 21 23 28 26 25 27 30 29 31 48 40 36 34 33 35 38 37 39 44 42 41 43 46 45 47 56 52 50 49 51 54 53 55 60 58 57 59 62 61 63 96 80 72 68 66 65 67 70 69 71 76 74 73 75 78 77 79 88 84 82 81 83 86 85 87 92 90 89 91 94 93 95 112 ...
result:
ok
Test #24:
score: 0
Accepted
time: 1ms
memory: 3608kb
input:
2048 11
output:
impossible
result:
ok
Test #25:
score: 0
Accepted
time: 0ms
memory: 3368kb
input:
65537 16
output:
impossible
result:
ok
Test #26:
score: 0
Accepted
time: 3ms
memory: 3608kb
input:
65534 16
output:
32767 16383 8191 4095 2047 1023 511 255 127 63 31 15 7 3 1 2 5 4 6 11 9 8 10 13 12 14 23 19 17 16 18 21 20 22 27 25 24 26 29 28 30 47 39 35 33 32 34 37 36 38 43 41 40 42 45 44 46 55 51 49 48 50 53 52 54 59 57 56 58 61 60 62 95 79 71 67 65 64 66 69 68 70 75 73 72 74 77 76 78 87 83 81 80 82 85 84 86 9...
result:
ok
Test #27:
score: 0
Accepted
time: 3ms
memory: 3376kb
input:
65535 16
output:
32768 16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1 3 6 5 7 12 10 9 11 14 13 15 24 20 18 17 19 22 21 23 28 26 25 27 30 29 31 48 40 36 34 33 35 38 37 39 44 42 41 43 46 45 47 56 52 50 49 51 54 53 55 60 58 57 59 62 61 63 96 80 72 68 66 65 67 70 69 71 76 74 73 75 78 77 79 88 84 82 81 83 86 85 8...
result:
ok
Test #28:
score: 0
Accepted
time: 1ms
memory: 3604kb
input:
131072 17
output:
impossible
result:
ok
Test #29:
score: 0
Accepted
time: 0ms
memory: 3388kb
input:
16385 14
output:
impossible
result:
ok
Test #30:
score: 0
Accepted
time: 3ms
memory: 3348kb
input:
60154 37250
output:
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
ok
Test #31:
score: 0
Accepted
time: 7ms
memory: 3452kb
input:
131517 28102
output:
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
ok
Test #32:
score: 0
Accepted
time: 9ms
memory: 3560kb
input:
185570 129405
output:
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
ok
Test #33:
score: 0
Accepted
time: 3ms
memory: 3436kb
input:
45486 4860
output:
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
ok
Test #34:
score: 0
Accepted
time: 5ms
memory: 3448kb
input:
108591 75200
output:
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
ok
Test #35:
score: 0
Accepted
time: 1ms
memory: 3448kb
input:
9982 6744
output:
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
ok
Test #36:
score: 0
Accepted
time: 2ms
memory: 3440kb
input:
45420 16088
output:
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
ok
Test #37:
score: 0
Accepted
time: 9ms
memory: 3616kb
input:
185780 19454
output:
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
ok
Test #38:
score: 0
Accepted
time: 1ms
memory: 3436kb
input:
7905 6430
output:
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
ok
Test #39:
score: 0
Accepted
time: 9ms
memory: 3608kb
input:
196560 181805
output:
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
ok