#include <bits/stdc++.h>
#include "monster.h"
using namespace std;
typedef long long ll;
namespace {
int n;
int arr[1002];
int arr2[1002];
void Sort(int l, int r){
if(l>=r) return;
int m = (l+r)>>1;
Sort(l, m);
Sort(m+1, r);
for(int i=l; i<=r; i++) arr2[i] = arr[i];
for(int i=l, j=m+1, k=l; k<=r; k++){
if(i==m+1) arr[k] = arr2[j++];
else if(j==r+1) arr[k] = arr2[i++];
else if(Query(arr2[i], arr2[j]) == 0) arr[k] = arr2[i++];
else arr[k] = arr2[j++];
}
}
int comp[1002];
}
vector<int> Solve(int N){
n = N;
for(int i=0; i<n; i++) arr[i] = i;
random_shuffle(arr, arr+n);
Sort(0, n-1);
for(int i=1; i<n; i++){
comp[i] = Query(arr[0], arr[i]);
}
if(accumulate(comp+1, comp+n, 0) == 1){ /// ù ���� 0 �Ǵ� 1
swap(arr[0], arr[1]);
}
else{
int tmp = accumulate(comp+1, comp+n, 0);
if(tmp == n-2){
if(Query(arr[1], arr[n-1])) reverse(arr, arr+n);
else reverse(arr, arr+n-1);
}
else{
reverse(arr, arr+tmp+1);
}
}
int tmp = 0;
for(int i=1; i<n; i++){
if(Query(arr[tmp], arr[i]) == 1){
reverse(arr+tmp+1, arr+i+1);
tmp = i;
}
}
// for(int i=0; i<n; i++) printf("%d ", arr[i]);
// puts("");
vector<int> idx (n);
for(int i=0; i<n; i++) idx[arr[i]] = i;
return idx;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Incorrect |
1 ms |
200 KB |
Wrong Answer [3] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Incorrect |
1 ms |
200 KB |
Wrong Answer [3] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
105 ms |
284 KB |
Partially correct |
2 |
Partially correct |
113 ms |
200 KB |
Partially correct |
3 |
Partially correct |
116 ms |
320 KB |
Partially correct |
4 |
Partially correct |
101 ms |
320 KB |
Partially correct |
5 |
Partially correct |
126 ms |
292 KB |
Partially correct |
6 |
Correct |
92 ms |
284 KB |
Output is correct |
7 |
Correct |
77 ms |
200 KB |
Output is correct |
8 |
Partially correct |
70 ms |
288 KB |
Partially correct |
9 |
Partially correct |
118 ms |
280 KB |
Partially correct |
10 |
Incorrect |
120 ms |
320 KB |
Wrong Answer [3] |
11 |
Halted |
0 ms |
0 KB |
- |