#include "monster.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
bool res[1010][1010];
vector<int> Solve(int N) {
n = N;
for (int i = 0;i < n;i++) {
for (int j = i + 1;j < n;j++) {
res[i][j] = Query(i, j);
res[j][i] = !res[i][j];
}
}
vector<int> ans;
set<int> rem;
for (int i = 0;i < n;i++) rem.insert(i);
while ((int)rem.size() > 1) {
int sec = 0;
for (auto& x : rem) {
int cnt = 0;
for (auto& y : rem) {
if (x != y) cnt += res[x][y];
}
if (cnt == (int)rem.size() - 1) {
sec = x;
break;
}
}
rem.erase(sec);
int fir = 0;
for (auto& x : rem) {
int cnt = 0;
for (auto& y : rem) {
if (y == x) continue;
cnt += res[x][y];
}
if (cnt == (int)rem.size() - 1) {
fir = x;
break;
}
}
ans.push_back(fir), ans.push_back(sec);
rem.erase(fir);
}
if (!rem.empty()) ans.push_back(*rem.begin());
reverse(ans.begin(), ans.end());
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [3] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [3] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
127 ms |
1404 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |