#include <bits/stdc++.h>
#ifndef LOCAL
#include "monster.h"
#endif
using namespace std;
vector<int> Solve(int n) {
vector<int> cntWin(n);
for (int i = 0; i < n; ++i) {
for (int j = i + 1; j < n; ++j) {
if (Query(i, j)) {
++cntWin[i];
} else {
++cntWin[j];
}
}
}
vector<int> order(n);
iota(order.begin(), order.end(), 0);
sort(order.begin(), order.end(), [&](const int& A, const int& B) {
return cntWin[A] < cntWin[B];
});
if (Query(order[1], order[0])) {
swap(order[0], order[1]);
}
if (Query(order[n - 1], order[n - 2])) {
swap(order[n - 2], order[n - 1]);
}
return order;
}
/*
void solve() {
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int T = 1;
cin >> T;
while (T--) {
solve();
cerr << "-----------\n";
cout << "-----------\n";
}
#else
int T = 1;
// cin >> T;
while (T--) {
solve();
}
#endif
return 0;
}
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
596 KB |
Wrong Answer [3] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
596 KB |
Wrong Answer [3] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
119 ms |
416 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |