#include <bits/stdc++.h>
#include "monster.h"
using namespace std;
namespace {
int qrs[256][256];
} // namespace
vector<int> Solve(int N) {
vector<int> T(N, -1);
for(int i = 0; i < N; i++){
for(int j = i+1; j < N; j++){
qrs[i][j] = Query(i, j);
qrs[j][i] = !qrs[i][j];
}
}
set<int> rem;
vector<int> cdd;
for(int i = 0; i < N; i++){
int sw = 0;
for(int j = 0; j < N; j++){
if(i == j) continue;
if(qrs[i][j]){
sw++;
}
}
if(sw == N-2){
cdd.push_back(i);
}
}
if(cdd.size() == 2){
if(!qrs[cdd.front()][cdd.back()]){
T[cdd.front()] = N-1;
}else{
T[cdd.back()] = N-1;
}
}else{
printf("Something is wrong at start\n");
}
for(int it = 0; it < N-1; it++){
cdd.clear();
for(int i = 0; i < N; i++){
if(rem.count(i)) continue;
int sw = 0;
for(int j = 0; j < N; j++){
if(rem.count(j)) continue;
if(i == j) continue;
if(qrs[i][j]){
sw++;
}
}
if(sw == 1){
cdd.push_back(i);
}
}
if(cdd.size() == 3){
for(int i = 0; i < 3; i++){
if(T[cdd[i]] == N-1){
cdd.erase(cdd.begin()+i);
break;
}
}
}
if(cdd.size() == 2){
if(qrs[cdd.front()][cdd.back()]){
T[cdd.front()] = it;
rem.insert(cdd.front());
}else{
T[cdd.back()] = it;
rem.insert(cdd.back());
}
}else if(cdd.size() == 1){
T[cdd.back()] = it;
}else{
printf("Something is wrong at %d: %d %d %d\n", it, cdd[0], cdd[1], cdd[2]);
}
}
return T;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
304 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
0 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
209 ms |
480 KB |
Output is correct |
17 |
Correct |
206 ms |
484 KB |
Output is correct |
18 |
Correct |
130 ms |
492 KB |
Output is correct |
19 |
Correct |
145 ms |
584 KB |
Output is correct |
20 |
Correct |
201 ms |
484 KB |
Output is correct |
21 |
Correct |
0 ms |
208 KB |
Output is correct |
22 |
Correct |
0 ms |
208 KB |
Output is correct |
23 |
Correct |
1 ms |
208 KB |
Output is correct |
24 |
Correct |
1 ms |
208 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
199 ms |
484 KB |
Output is correct |
27 |
Correct |
0 ms |
208 KB |
Output is correct |
28 |
Correct |
0 ms |
208 KB |
Output is correct |
29 |
Correct |
1 ms |
208 KB |
Output is correct |
30 |
Correct |
1 ms |
208 KB |
Output is correct |
31 |
Correct |
1 ms |
208 KB |
Output is correct |
32 |
Correct |
142 ms |
500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
304 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
0 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
209 ms |
480 KB |
Output is correct |
17 |
Correct |
206 ms |
484 KB |
Output is correct |
18 |
Correct |
130 ms |
492 KB |
Output is correct |
19 |
Correct |
145 ms |
584 KB |
Output is correct |
20 |
Correct |
201 ms |
484 KB |
Output is correct |
21 |
Correct |
0 ms |
208 KB |
Output is correct |
22 |
Correct |
0 ms |
208 KB |
Output is correct |
23 |
Correct |
1 ms |
208 KB |
Output is correct |
24 |
Correct |
1 ms |
208 KB |
Output is correct |
25 |
Correct |
1 ms |
208 KB |
Output is correct |
26 |
Correct |
199 ms |
484 KB |
Output is correct |
27 |
Correct |
0 ms |
208 KB |
Output is correct |
28 |
Correct |
0 ms |
208 KB |
Output is correct |
29 |
Correct |
1 ms |
208 KB |
Output is correct |
30 |
Correct |
1 ms |
208 KB |
Output is correct |
31 |
Correct |
1 ms |
208 KB |
Output is correct |
32 |
Correct |
142 ms |
500 KB |
Output is correct |
33 |
Runtime error |
3 ms |
848 KB |
Execution killed with signal 11 |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
848 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |