109872024-05-02 15:36:02mraronKutyák és macskákcpp17Accepted 100/1001.128s716 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());
}

SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms356 KiB
2Accepted1.009s532 KiB
subtask26/6
3Accepted1.026s440 KiB
4Accepted978ms548 KiB
5Accepted1.009s532 KiB
6Accepted947ms564 KiB
7Accepted1.021s536 KiB
subtask37/7
8Accepted3ms304 KiB
9Accepted3ms504 KiB
10Accepted4ms420 KiB
11Accepted4ms452 KiB
12Accepted3ms228 KiB
13Accepted30ms384 KiB
14Accepted37ms356 KiB
subtask410/10
15Accepted8ms352 KiB
16Accepted8ms552 KiB
17Accepted8ms364 KiB
18Accepted8ms504 KiB
19Accepted8ms536 KiB
20Accepted8ms412 KiB
21Accepted8ms380 KiB
22Accepted9ms384 KiB
23Accepted10ms384 KiB
24Accepted9ms424 KiB
25Accepted12ms228 KiB
26Accepted10ms384 KiB
27Accepted8ms356 KiB
28Accepted12ms520 KiB
29Accepted14ms484 KiB
subtask512/12
30Accepted8ms352 KiB
31Accepted8ms552 KiB
32Accepted8ms364 KiB
33Accepted8ms504 KiB
34Accepted8ms536 KiB
35Accepted8ms412 KiB
36Accepted8ms380 KiB
37Accepted9ms384 KiB
38Accepted10ms384 KiB
39Accepted9ms424 KiB
40Accepted12ms228 KiB
41Accepted10ms384 KiB
42Accepted8ms356 KiB
43Accepted12ms520 KiB
44Accepted14ms484 KiB
45Accepted48ms320 KiB
46Accepted46ms400 KiB
47Accepted46ms228 KiB
48Accepted45ms356 KiB
49Accepted46ms356 KiB
50Accepted46ms400 KiB
51Accepted46ms484 KiB
52Accepted48ms300 KiB
53Accepted41ms404 KiB
54Accepted43ms488 KiB
55Accepted37ms356 KiB
56Accepted46ms408 KiB
57Accepted39ms356 KiB
58Accepted56ms512 KiB
59Accepted52ms504 KiB
subtask665/65
60Accepted3ms356 KiB
61Accepted1.128s456 KiB
62Accepted1.026s440 KiB
63Accepted978ms548 KiB
64Accepted1.009s532 KiB
65Accepted947ms564 KiB
66Accepted1.021s536 KiB
67Accepted3ms304 KiB
68Accepted3ms504 KiB
69Accepted4ms420 KiB
70Accepted4ms452 KiB
71Accepted3ms228 KiB
72Accepted30ms384 KiB
73Accepted37ms356 KiB
74Accepted8ms352 KiB
75Accepted8ms552 KiB
76Accepted8ms364 KiB
77Accepted8ms504 KiB
78Accepted8ms536 KiB
79Accepted8ms412 KiB
80Accepted8ms380 KiB
81Accepted9ms384 KiB
82Accepted10ms384 KiB
83Accepted9ms424 KiB
84Accepted12ms228 KiB
85Accepted10ms384 KiB
86Accepted8ms356 KiB
87Accepted12ms520 KiB
88Accepted14ms484 KiB
89Accepted48ms320 KiB
90Accepted46ms400 KiB
91Accepted46ms228 KiB
92Accepted45ms356 KiB
93Accepted46ms356 KiB
94Accepted46ms400 KiB
95Accepted46ms484 KiB
96Accepted48ms300 KiB
97Accepted41ms404 KiB
98Accepted43ms488 KiB
99Accepted37ms356 KiB
100Accepted46ms408 KiB
101Accepted39ms356 KiB
102Accepted56ms512 KiB
103Accepted52ms504 KiB
104Accepted981ms716 KiB
105Accepted980ms424 KiB
106Accepted1.126s632 KiB
107Accepted994ms612 KiB
108Accepted1.008s616 KiB
109Accepted972ms676 KiB
110Accepted986ms548 KiB
111Accepted1.014s552 KiB
112Accepted985ms564 KiB
113Accepted978ms552 KiB
114Accepted982ms536 KiB
115Accepted989ms508 KiB
116Accepted1.019s504 KiB
117Accepted1.041s440 KiB
118Accepted1.046s436 KiB
119Accepted1.014s484 KiB
120Accepted1.042s532 KiB
121Accepted987ms576 KiB
122Accepted1.001s484 KiB
123Accepted976ms684 KiB
124Accepted981ms584 KiB
125Accepted968ms544 KiB
126Accepted1.054s632 KiB
127Accepted1.036s664 KiB
128Accepted1.042s576 KiB
129Accepted1.011s540 KiB
130Accepted1.031s684 KiB
131Accepted939ms576 KiB
132Accepted986ms676 KiB