#include<vector>
using namespace std;
#define vi vector<int>
bool Query(int a, int b);
void sorti(vi &v){
vi v1,v2;
int s = v.size();
if(s==1)return;
for(int i = 0; i <s/2; i++ )v1.push_back(v[i]);
for(int i = s/2; i < s; i++)v2.push_back(v[i]);
sorti(v1);
sorti(v2);
vi vt;
int it = 0;
for(int i= 0; i < s/2; i++){
while(it < v2.size() && !Query(v2[it],v1[i])){
vt.push_back(v2[it]);
it++;
}vt.push_back(v1[i]);
}
while(it < v2.size()){
vt.push_back(v2[it]);
it++;
}
v=vt;
}
int n;
int find(int ind){
int sum = 0;
vi win,lose;
for(int i = 0; i < n; i++){
if(ind == i)continue;
if(Query(ind,i))win.push_back(i);
else lose.push_back(i);
}
if(win.size()==1){
int sum = 0;
for(int i = 0; i < n; i++){
if(i!=win[0]){
sum += Query(win[0],i);
if(sum == 2)return 1;
}
}
return 0;
}else if(lose.size() == 1){
int sum = 0;
for(int i = 0; i < n; i++){
if(i!=lose[0]){
sum += Query(i,lose[0]);
if(sum == 2)return n-2;
}
}
return n-1;
}else{
return win.size();
}
}
std::vector<int> Solve(int N) {
n=N;
std::vector<int> ans;
vi v; for(int i = 0; i <N; i++)v.push_back(i);
sorti(v);
vi res(N);
int l = 0,r = find(v[0]);
for(int i = r; i>=0; i--)ans.push_back(i);
while(ans.size()<N){
int lt = r+1;
for(int i = lt; i < N; i++){
if(Query(v[l],v[i])){
l = lt;
r = i;
for(int j = r; j>=l; j--)ans.push_back(j);
break;
}
}
}
for(int i = 0; i < N; i++){
res[v[i]] = ans[i];
}
return res;
}
Compilation message
monster.cpp: In function 'void sorti(std::vector<int>&)':
monster.cpp:18:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | while(it < v2.size() && !Query(v2[it],v1[i])){
| ~~~^~~~~~~~~~~
monster.cpp:23:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | while(it < v2.size()){
| ~~~^~~~~~~~~~~
monster.cpp: In function 'int find(int)':
monster.cpp:31:7: warning: unused variable 'sum' [-Wunused-variable]
31 | int sum = 0;
| ^~~
monster.cpp: In function 'std::vector<int> Solve(int)':
monster.cpp:68:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
68 | while(ans.size()<N){
| ~~~~~~~~~~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
8 ms |
344 KB |
Output is correct |
17 |
Correct |
7 ms |
344 KB |
Output is correct |
18 |
Correct |
8 ms |
424 KB |
Output is correct |
19 |
Correct |
8 ms |
428 KB |
Output is correct |
20 |
Correct |
8 ms |
424 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
0 ms |
344 KB |
Output is correct |
25 |
Correct |
0 ms |
344 KB |
Output is correct |
26 |
Correct |
7 ms |
432 KB |
Output is correct |
27 |
Correct |
0 ms |
344 KB |
Output is correct |
28 |
Correct |
0 ms |
344 KB |
Output is correct |
29 |
Correct |
0 ms |
344 KB |
Output is correct |
30 |
Correct |
0 ms |
344 KB |
Output is correct |
31 |
Correct |
0 ms |
344 KB |
Output is correct |
32 |
Correct |
5 ms |
424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
8 ms |
344 KB |
Output is correct |
17 |
Correct |
7 ms |
344 KB |
Output is correct |
18 |
Correct |
8 ms |
424 KB |
Output is correct |
19 |
Correct |
8 ms |
428 KB |
Output is correct |
20 |
Correct |
8 ms |
424 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
0 ms |
344 KB |
Output is correct |
25 |
Correct |
0 ms |
344 KB |
Output is correct |
26 |
Correct |
7 ms |
432 KB |
Output is correct |
27 |
Correct |
0 ms |
344 KB |
Output is correct |
28 |
Correct |
0 ms |
344 KB |
Output is correct |
29 |
Correct |
0 ms |
344 KB |
Output is correct |
30 |
Correct |
0 ms |
344 KB |
Output is correct |
31 |
Correct |
0 ms |
344 KB |
Output is correct |
32 |
Correct |
5 ms |
424 KB |
Output is correct |
33 |
Correct |
38 ms |
344 KB |
Output is correct |
34 |
Correct |
39 ms |
344 KB |
Output is correct |
35 |
Correct |
46 ms |
412 KB |
Output is correct |
36 |
Correct |
59 ms |
592 KB |
Output is correct |
37 |
Correct |
43 ms |
344 KB |
Output is correct |
38 |
Correct |
36 ms |
412 KB |
Output is correct |
39 |
Correct |
44 ms |
432 KB |
Output is correct |
40 |
Correct |
43 ms |
416 KB |
Output is correct |
41 |
Correct |
60 ms |
436 KB |
Output is correct |
42 |
Correct |
47 ms |
600 KB |
Output is correct |
43 |
Correct |
35 ms |
428 KB |
Output is correct |
44 |
Correct |
33 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
43 ms |
416 KB |
Partially correct |
2 |
Partially correct |
41 ms |
416 KB |
Partially correct |
3 |
Partially correct |
43 ms |
600 KB |
Partially correct |
4 |
Partially correct |
51 ms |
428 KB |
Partially correct |
5 |
Partially correct |
62 ms |
600 KB |
Partially correct |
6 |
Correct |
26 ms |
416 KB |
Output is correct |
7 |
Partially correct |
58 ms |
592 KB |
Partially correct |
8 |
Partially correct |
43 ms |
436 KB |
Partially correct |
9 |
Partially correct |
58 ms |
672 KB |
Partially correct |
10 |
Partially correct |
60 ms |
600 KB |
Partially correct |
11 |
Partially correct |
54 ms |
416 KB |
Partially correct |
12 |
Partially correct |
50 ms |
600 KB |
Partially correct |
13 |
Correct |
31 ms |
344 KB |
Output is correct |
14 |
Partially correct |
60 ms |
412 KB |
Partially correct |
15 |
Correct |
35 ms |
432 KB |
Output is correct |
16 |
Correct |
28 ms |
344 KB |
Output is correct |
17 |
Partially correct |
54 ms |
416 KB |
Partially correct |
18 |
Correct |
36 ms |
600 KB |
Output is correct |