#include "monster.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
vector<vector<int>> QQ;
bool query(int a, int b){
if(a > b){
if(QQ[b][a] == -1) QQ[b][a] = Query(b, a);
return !QQ[b][a];
}
else{
if(QQ[a][b] == -1) QQ[a][b] = Query(a, b);
return QQ[a][b];
}
}
vector<int> Solve(int n){
QQ = vector<vector<int>>(n, vector<int>(n, -1));
vector<int> sth(n);
for(int i = 0; i < n; i++) sth[i] = i;
random_shuffle(sth.begin(), sth.end());
stable_sort(sth.begin(), sth.end(), [&](int x, int y){
return query(y, x);
});
auto win = [=](int x){
vector<int> rt;
for(int i = 0; i < n; i++) if(i != x && query(x, i)) rt.pb(i);
return rt;
};
int z = -1, k = min(n, 10);
vector<int> cnt(k, 0), ss(k);
for(int i = 0; i < k; i++) ss[i] = i;
for(int i = 0; i < k; i++){
for(int j = 0; j < k; j++) if(i != j) cnt[i]+=query(sth[i], sth[j]);
}
sort(ss.begin(), ss.end(), [&](int x, int y){
return cnt[x] < cnt[y];
});
if(query(sth[ss[0]], sth[ss[1]])) z = ss[0];
else z = ss[1];
reverse(sth.begin(), sth.begin()+z+1);
for(;z+1 < n; z++){
for(int i = z+1; i < n; i++) if(query(sth[z], sth[i])){
reverse(sth.begin()+z+1, sth.begin()+i+1);
z = i;
}
}
vector<int> ans(n);
for(int i = 0; i < n; i++) ans[sth[i]] = i;
return ans;
}
Compilation message
monster.cpp: In function 'std::vector<int> Solve(int)':
monster.cpp:32:10: warning: variable 'win' set but not used [-Wunused-but-set-variable]
32 | auto win = [=](int x){
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
284 KB |
Output is correct |
2 |
Correct |
0 ms |
284 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
0 ms |
200 KB |
Output is correct |
6 |
Correct |
0 ms |
200 KB |
Output is correct |
7 |
Correct |
1 ms |
200 KB |
Output is correct |
8 |
Correct |
0 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 |
288 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 |
288 KB |
Output is correct |
16 |
Correct |
12 ms |
328 KB |
Output is correct |
17 |
Correct |
7 ms |
328 KB |
Output is correct |
18 |
Correct |
15 ms |
328 KB |
Output is correct |
19 |
Correct |
12 ms |
328 KB |
Output is correct |
20 |
Correct |
17 ms |
328 KB |
Output is correct |
21 |
Correct |
0 ms |
200 KB |
Output is correct |
22 |
Correct |
1 ms |
208 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 |
15 ms |
328 KB |
Output is correct |
27 |
Correct |
0 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 |
284 KB |
Output is correct |
32 |
Correct |
7 ms |
408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
284 KB |
Output is correct |
2 |
Correct |
0 ms |
284 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
0 ms |
200 KB |
Output is correct |
6 |
Correct |
0 ms |
200 KB |
Output is correct |
7 |
Correct |
1 ms |
200 KB |
Output is correct |
8 |
Correct |
0 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 |
288 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 |
288 KB |
Output is correct |
16 |
Correct |
12 ms |
328 KB |
Output is correct |
17 |
Correct |
7 ms |
328 KB |
Output is correct |
18 |
Correct |
15 ms |
328 KB |
Output is correct |
19 |
Correct |
12 ms |
328 KB |
Output is correct |
20 |
Correct |
17 ms |
328 KB |
Output is correct |
21 |
Correct |
0 ms |
200 KB |
Output is correct |
22 |
Correct |
1 ms |
208 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 |
15 ms |
328 KB |
Output is correct |
27 |
Correct |
0 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 |
284 KB |
Output is correct |
32 |
Correct |
7 ms |
408 KB |
Output is correct |
33 |
Correct |
75 ms |
4244 KB |
Output is correct |
34 |
Correct |
87 ms |
4196 KB |
Output is correct |
35 |
Correct |
107 ms |
4168 KB |
Output is correct |
36 |
Correct |
81 ms |
4208 KB |
Output is correct |
37 |
Correct |
70 ms |
4228 KB |
Output is correct |
38 |
Correct |
100 ms |
4240 KB |
Output is correct |
39 |
Correct |
103 ms |
4120 KB |
Output is correct |
40 |
Correct |
80 ms |
4228 KB |
Output is correct |
41 |
Correct |
102 ms |
4232 KB |
Output is correct |
42 |
Correct |
86 ms |
4232 KB |
Output is correct |
43 |
Correct |
92 ms |
4288 KB |
Output is correct |
44 |
Correct |
91 ms |
4168 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
97 ms |
4212 KB |
Partially correct |
2 |
Partially correct |
96 ms |
4232 KB |
Partially correct |
3 |
Partially correct |
87 ms |
4232 KB |
Partially correct |
4 |
Partially correct |
102 ms |
4232 KB |
Partially correct |
5 |
Partially correct |
103 ms |
4168 KB |
Partially correct |
6 |
Correct |
50 ms |
4232 KB |
Output is correct |
7 |
Correct |
79 ms |
4232 KB |
Output is correct |
8 |
Partially correct |
89 ms |
4208 KB |
Partially correct |
9 |
Partially correct |
81 ms |
4228 KB |
Partially correct |
10 |
Partially correct |
112 ms |
4236 KB |
Partially correct |
11 |
Partially correct |
85 ms |
4228 KB |
Partially correct |
12 |
Partially correct |
91 ms |
4232 KB |
Partially correct |
13 |
Correct |
85 ms |
4232 KB |
Output is correct |
14 |
Correct |
88 ms |
4228 KB |
Output is correct |
15 |
Correct |
56 ms |
4168 KB |
Output is correct |
16 |
Correct |
47 ms |
4228 KB |
Output is correct |
17 |
Correct |
86 ms |
4168 KB |
Output is correct |
18 |
Correct |
54 ms |
4232 KB |
Output is correct |