10987 | 2024-05-02 15:36:02 | mraron | Kutyák és macskák | cpp17 | Accepted 100/100 | 1.128s | 716 KiB |
#include "KutyakMacskak.h"
#include<algorithm>
#include<numeric>
#include<queue>
std::vector<int> find_order(int N, int M) {
std::vector<int> ms(M); std::iota(ms.begin(), ms.end(), 1);
std::vector<int> res={ms[0]};
for(int i=1;i<ms.size();++i) {
auto it=upper_bound(res.begin(), res.end(), ms[i], [](int x, int y) -> bool {
return ask(1, x, y)==x;
});
res.insert(it, ms[i]);
}
int kind=2;
while(kind<=N) {
if(ask(kind, res.front(), res.back())==res.back()) {
break ;
}
kind++;
}
std::deque<int> ans;
for(int i=0;i<M;++i) {
if(res[i]==res.front()) {
ans.push_front(res[i]);
}else if(res[i]==res.back()) {
ans.push_back(res[i]);
}else {
if(ask(kind, res[i], res.front())==res[i]) {
ans.push_back(res[i]);
}else {
ans.push_front(res[i]);
}
}
}
return std::vector<int>(ans.begin(), ans.end());
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 356 KiB | ||||
2 | Accepted | 1.009s | 532 KiB | ||||
subtask2 | 6/6 | ||||||
3 | Accepted | 1.026s | 440 KiB | ||||
4 | Accepted | 978ms | 548 KiB | ||||
5 | Accepted | 1.009s | 532 KiB | ||||
6 | Accepted | 947ms | 564 KiB | ||||
7 | Accepted | 1.021s | 536 KiB | ||||
subtask3 | 7/7 | ||||||
8 | Accepted | 3ms | 304 KiB | ||||
9 | Accepted | 3ms | 504 KiB | ||||
10 | Accepted | 4ms | 420 KiB | ||||
11 | Accepted | 4ms | 452 KiB | ||||
12 | Accepted | 3ms | 228 KiB | ||||
13 | Accepted | 30ms | 384 KiB | ||||
14 | Accepted | 37ms | 356 KiB | ||||
subtask4 | 10/10 | ||||||
15 | Accepted | 8ms | 352 KiB | ||||
16 | Accepted | 8ms | 552 KiB | ||||
17 | Accepted | 8ms | 364 KiB | ||||
18 | Accepted | 8ms | 504 KiB | ||||
19 | Accepted | 8ms | 536 KiB | ||||
20 | Accepted | 8ms | 412 KiB | ||||
21 | Accepted | 8ms | 380 KiB | ||||
22 | Accepted | 9ms | 384 KiB | ||||
23 | Accepted | 10ms | 384 KiB | ||||
24 | Accepted | 9ms | 424 KiB | ||||
25 | Accepted | 12ms | 228 KiB | ||||
26 | Accepted | 10ms | 384 KiB | ||||
27 | Accepted | 8ms | 356 KiB | ||||
28 | Accepted | 12ms | 520 KiB | ||||
29 | Accepted | 14ms | 484 KiB | ||||
subtask5 | 12/12 | ||||||
30 | Accepted | 8ms | 352 KiB | ||||
31 | Accepted | 8ms | 552 KiB | ||||
32 | Accepted | 8ms | 364 KiB | ||||
33 | Accepted | 8ms | 504 KiB | ||||
34 | Accepted | 8ms | 536 KiB | ||||
35 | Accepted | 8ms | 412 KiB | ||||
36 | Accepted | 8ms | 380 KiB | ||||
37 | Accepted | 9ms | 384 KiB | ||||
38 | Accepted | 10ms | 384 KiB | ||||
39 | Accepted | 9ms | 424 KiB | ||||
40 | Accepted | 12ms | 228 KiB | ||||
41 | Accepted | 10ms | 384 KiB | ||||
42 | Accepted | 8ms | 356 KiB | ||||
43 | Accepted | 12ms | 520 KiB | ||||
44 | Accepted | 14ms | 484 KiB | ||||
45 | Accepted | 48ms | 320 KiB | ||||
46 | Accepted | 46ms | 400 KiB | ||||
47 | Accepted | 46ms | 228 KiB | ||||
48 | Accepted | 45ms | 356 KiB | ||||
49 | Accepted | 46ms | 356 KiB | ||||
50 | Accepted | 46ms | 400 KiB | ||||
51 | Accepted | 46ms | 484 KiB | ||||
52 | Accepted | 48ms | 300 KiB | ||||
53 | Accepted | 41ms | 404 KiB | ||||
54 | Accepted | 43ms | 488 KiB | ||||
55 | Accepted | 37ms | 356 KiB | ||||
56 | Accepted | 46ms | 408 KiB | ||||
57 | Accepted | 39ms | 356 KiB | ||||
58 | Accepted | 56ms | 512 KiB | ||||
59 | Accepted | 52ms | 504 KiB | ||||
subtask6 | 65/65 | ||||||
60 | Accepted | 3ms | 356 KiB | ||||
61 | Accepted | 1.128s | 456 KiB | ||||
62 | Accepted | 1.026s | 440 KiB | ||||
63 | Accepted | 978ms | 548 KiB | ||||
64 | Accepted | 1.009s | 532 KiB | ||||
65 | Accepted | 947ms | 564 KiB | ||||
66 | Accepted | 1.021s | 536 KiB | ||||
67 | Accepted | 3ms | 304 KiB | ||||
68 | Accepted | 3ms | 504 KiB | ||||
69 | Accepted | 4ms | 420 KiB | ||||
70 | Accepted | 4ms | 452 KiB | ||||
71 | Accepted | 3ms | 228 KiB | ||||
72 | Accepted | 30ms | 384 KiB | ||||
73 | Accepted | 37ms | 356 KiB | ||||
74 | Accepted | 8ms | 352 KiB | ||||
75 | Accepted | 8ms | 552 KiB | ||||
76 | Accepted | 8ms | 364 KiB | ||||
77 | Accepted | 8ms | 504 KiB | ||||
78 | Accepted | 8ms | 536 KiB | ||||
79 | Accepted | 8ms | 412 KiB | ||||
80 | Accepted | 8ms | 380 KiB | ||||
81 | Accepted | 9ms | 384 KiB | ||||
82 | Accepted | 10ms | 384 KiB | ||||
83 | Accepted | 9ms | 424 KiB | ||||
84 | Accepted | 12ms | 228 KiB | ||||
85 | Accepted | 10ms | 384 KiB | ||||
86 | Accepted | 8ms | 356 KiB | ||||
87 | Accepted | 12ms | 520 KiB | ||||
88 | Accepted | 14ms | 484 KiB | ||||
89 | Accepted | 48ms | 320 KiB | ||||
90 | Accepted | 46ms | 400 KiB | ||||
91 | Accepted | 46ms | 228 KiB | ||||
92 | Accepted | 45ms | 356 KiB | ||||
93 | Accepted | 46ms | 356 KiB | ||||
94 | Accepted | 46ms | 400 KiB | ||||
95 | Accepted | 46ms | 484 KiB | ||||
96 | Accepted | 48ms | 300 KiB | ||||
97 | Accepted | 41ms | 404 KiB | ||||
98 | Accepted | 43ms | 488 KiB | ||||
99 | Accepted | 37ms | 356 KiB | ||||
100 | Accepted | 46ms | 408 KiB | ||||
101 | Accepted | 39ms | 356 KiB | ||||
102 | Accepted | 56ms | 512 KiB | ||||
103 | Accepted | 52ms | 504 KiB | ||||
104 | Accepted | 981ms | 716 KiB | ||||
105 | Accepted | 980ms | 424 KiB | ||||
106 | Accepted | 1.126s | 632 KiB | ||||
107 | Accepted | 994ms | 612 KiB | ||||
108 | Accepted | 1.008s | 616 KiB | ||||
109 | Accepted | 972ms | 676 KiB | ||||
110 | Accepted | 986ms | 548 KiB | ||||
111 | Accepted | 1.014s | 552 KiB | ||||
112 | Accepted | 985ms | 564 KiB | ||||
113 | Accepted | 978ms | 552 KiB | ||||
114 | Accepted | 982ms | 536 KiB | ||||
115 | Accepted | 989ms | 508 KiB | ||||
116 | Accepted | 1.019s | 504 KiB | ||||
117 | Accepted | 1.041s | 440 KiB | ||||
118 | Accepted | 1.046s | 436 KiB | ||||
119 | Accepted | 1.014s | 484 KiB | ||||
120 | Accepted | 1.042s | 532 KiB | ||||
121 | Accepted | 987ms | 576 KiB | ||||
122 | Accepted | 1.001s | 484 KiB | ||||
123 | Accepted | 976ms | 684 KiB | ||||
124 | Accepted | 981ms | 584 KiB | ||||
125 | Accepted | 968ms | 544 KiB | ||||
126 | Accepted | 1.054s | 632 KiB | ||||
127 | Accepted | 1.036s | 664 KiB | ||||
128 | Accepted | 1.042s | 576 KiB | ||||
129 | Accepted | 1.011s | 540 KiB | ||||
130 | Accepted | 1.031s | 684 KiB | ||||
131 | Accepted | 939ms | 576 KiB | ||||
132 | Accepted | 986ms | 676 KiB |