#include "monster.h"
#include <vector>
#include <cstdio>
#include <ctime>
#include <algorithm>
#include <unistd.h>
#define PB push_back
using namespace std;
typedef vector < int > vi;
namespace {
bool example_variable;
void merge_sort(vi &v){
if((int)v.size() <= 1) return;
vi A[2];
for(int i = 0;i < (int)v.size();i++)
A[i & 1].PB(v[i]);
merge_sort(A[0]); merge_sort(A[1]);
v.clear();
int i = 0, j = 0;
for(;i < (int)A[0].size() || j < (int)A[1].size();){
if(i == (int)A[0].size()) v.PB(A[1][j++]);
else if(j == (int)A[1].size()) v.PB(A[0][i++]);
else if(!Query(A[0][i], A[1][j])) v.PB(A[0][i++]);
else v.PB(A[1][j++]);
}
}
} // namespace
vi Solve(int n) {
vi v, ret(n);
for(int i = 0;i < n;i++)
v.PB(i);
merge_sort(v);
int pref = 0, cnt = 0;
for(int i = 1;i < n;i++)
cnt += Query(v[0], v[i]);
if(cnt == 1){
int cnt2 = 0;
for(int i = 2;i < n;i++)
cnt2 += Query(v[1], v[i]);
if(cnt2 == 0)
pref = 1;
else
pref = 0;
}
else
pref = cnt;
int lst = pref;
reverse(v.begin(), v.begin() + pref + 1);
for(int i = lst + 1;i < n;i++){
while(i < (int)v.size() && !Query(v[lst], v[i]))
i++;
reverse(v.begin() + lst + 1, v.begin() + i + 1);
lst = i;
}
for(int i = 0;i < n;i++)
ret[v[i]] = i;
return ret;
}
Compilation message
monster.cpp:16:6: warning: '{anonymous}::example_variable' defined but not used [-Wunused-variable]
16 | bool example_variable;
| ^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
0 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
200 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
200 KB |
Output is correct |
12 |
Correct |
1 ms |
200 KB |
Output is correct |
13 |
Correct |
1 ms |
200 KB |
Output is correct |
14 |
Correct |
1 ms |
200 KB |
Output is correct |
15 |
Correct |
1 ms |
200 KB |
Output is correct |
16 |
Correct |
15 ms |
200 KB |
Output is correct |
17 |
Correct |
24 ms |
200 KB |
Output is correct |
18 |
Correct |
22 ms |
200 KB |
Output is correct |
19 |
Correct |
16 ms |
200 KB |
Output is correct |
20 |
Correct |
11 ms |
200 KB |
Output is correct |
21 |
Correct |
1 ms |
200 KB |
Output is correct |
22 |
Correct |
1 ms |
200 KB |
Output is correct |
23 |
Correct |
1 ms |
200 KB |
Output is correct |
24 |
Correct |
1 ms |
200 KB |
Output is correct |
25 |
Correct |
1 ms |
200 KB |
Output is correct |
26 |
Correct |
16 ms |
200 KB |
Output is correct |
27 |
Correct |
1 ms |
200 KB |
Output is correct |
28 |
Correct |
1 ms |
200 KB |
Output is correct |
29 |
Correct |
1 ms |
200 KB |
Output is correct |
30 |
Correct |
1 ms |
200 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
22 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
0 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
200 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
200 KB |
Output is correct |
12 |
Correct |
1 ms |
200 KB |
Output is correct |
13 |
Correct |
1 ms |
200 KB |
Output is correct |
14 |
Correct |
1 ms |
200 KB |
Output is correct |
15 |
Correct |
1 ms |
200 KB |
Output is correct |
16 |
Correct |
15 ms |
200 KB |
Output is correct |
17 |
Correct |
24 ms |
200 KB |
Output is correct |
18 |
Correct |
22 ms |
200 KB |
Output is correct |
19 |
Correct |
16 ms |
200 KB |
Output is correct |
20 |
Correct |
11 ms |
200 KB |
Output is correct |
21 |
Correct |
1 ms |
200 KB |
Output is correct |
22 |
Correct |
1 ms |
200 KB |
Output is correct |
23 |
Correct |
1 ms |
200 KB |
Output is correct |
24 |
Correct |
1 ms |
200 KB |
Output is correct |
25 |
Correct |
1 ms |
200 KB |
Output is correct |
26 |
Correct |
16 ms |
200 KB |
Output is correct |
27 |
Correct |
1 ms |
200 KB |
Output is correct |
28 |
Correct |
1 ms |
200 KB |
Output is correct |
29 |
Correct |
1 ms |
200 KB |
Output is correct |
30 |
Correct |
1 ms |
200 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
22 ms |
200 KB |
Output is correct |
33 |
Correct |
95 ms |
200 KB |
Output is correct |
34 |
Correct |
96 ms |
200 KB |
Output is correct |
35 |
Correct |
124 ms |
200 KB |
Output is correct |
36 |
Correct |
58 ms |
200 KB |
Output is correct |
37 |
Correct |
149 ms |
256 KB |
Output is correct |
38 |
Correct |
138 ms |
200 KB |
Output is correct |
39 |
Correct |
100 ms |
200 KB |
Output is correct |
40 |
Correct |
132 ms |
200 KB |
Output is correct |
41 |
Correct |
130 ms |
200 KB |
Output is correct |
42 |
Correct |
103 ms |
200 KB |
Output is correct |
43 |
Correct |
131 ms |
200 KB |
Output is correct |
44 |
Correct |
141 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
92 ms |
200 KB |
Partially correct |
2 |
Partially correct |
84 ms |
200 KB |
Partially correct |
3 |
Partially correct |
97 ms |
200 KB |
Partially correct |
4 |
Partially correct |
124 ms |
200 KB |
Partially correct |
5 |
Partially correct |
109 ms |
200 KB |
Partially correct |
6 |
Partially correct |
80 ms |
200 KB |
Partially correct |
7 |
Partially correct |
114 ms |
200 KB |
Partially correct |
8 |
Partially correct |
144 ms |
200 KB |
Partially correct |
9 |
Partially correct |
125 ms |
200 KB |
Partially correct |
10 |
Partially correct |
128 ms |
200 KB |
Partially correct |
11 |
Partially correct |
117 ms |
200 KB |
Partially correct |
12 |
Partially correct |
97 ms |
200 KB |
Partially correct |
13 |
Partially correct |
121 ms |
200 KB |
Partially correct |
14 |
Partially correct |
134 ms |
200 KB |
Partially correct |
15 |
Correct |
80 ms |
200 KB |
Output is correct |
16 |
Correct |
34 ms |
200 KB |
Output is correct |
17 |
Correct |
117 ms |
200 KB |
Output is correct |
18 |
Correct |
101 ms |
200 KB |
Output is correct |