# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
423463 |
2021-06-11T07:25:10 Z |
반딧불(#7610) |
Monster Game (JOI21_monster) |
C++17 |
|
112 ms |
320 KB |
#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(i==3 && comp[2] && !comp[3]) break;
}
if(accumulate(comp+1, comp+n, 0) == 1){ /// ù ���� 0 �Ǵ� 1
int tmp = find(comp+1, comp+n, 1) - comp;
if(tmp == 1) {} /// ù ���� 0�̴�.
else if(tmp != 2){
if(Query(arr[1], arr[tmp])) {} /// ù ���� 0�̴�.
else swap(arr[0], arr[1]); /// ù ���� 1�̹Ƿ� ��ȯ�Ѵ�.
}
else{
int sum = 0;
for(int i=3; i<n; i++){
sum += Query(arr[1], arr[i]);
if(sum) break;
}
if(sum) {}
else 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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
284 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
1 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
200 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
200 KB |
Output is correct |
12 |
Correct |
1 ms |
200 KB |
Output is correct |
13 |
Correct |
1 ms |
200 KB |
Output is correct |
14 |
Correct |
1 ms |
200 KB |
Output is correct |
15 |
Correct |
1 ms |
200 KB |
Output is correct |
16 |
Correct |
19 ms |
200 KB |
Output is correct |
17 |
Correct |
20 ms |
200 KB |
Output is correct |
18 |
Correct |
13 ms |
200 KB |
Output is correct |
19 |
Correct |
15 ms |
200 KB |
Output is correct |
20 |
Correct |
20 ms |
200 KB |
Output is correct |
21 |
Correct |
1 ms |
200 KB |
Output is correct |
22 |
Correct |
1 ms |
200 KB |
Output is correct |
23 |
Correct |
1 ms |
200 KB |
Output is correct |
24 |
Correct |
1 ms |
280 KB |
Output is correct |
25 |
Correct |
1 ms |
200 KB |
Output is correct |
26 |
Correct |
14 ms |
200 KB |
Output is correct |
27 |
Correct |
1 ms |
200 KB |
Output is correct |
28 |
Incorrect |
1 ms |
200 KB |
Wrong Answer [3] |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
284 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
1 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
200 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
200 KB |
Output is correct |
12 |
Correct |
1 ms |
200 KB |
Output is correct |
13 |
Correct |
1 ms |
200 KB |
Output is correct |
14 |
Correct |
1 ms |
200 KB |
Output is correct |
15 |
Correct |
1 ms |
200 KB |
Output is correct |
16 |
Correct |
19 ms |
200 KB |
Output is correct |
17 |
Correct |
20 ms |
200 KB |
Output is correct |
18 |
Correct |
13 ms |
200 KB |
Output is correct |
19 |
Correct |
15 ms |
200 KB |
Output is correct |
20 |
Correct |
20 ms |
200 KB |
Output is correct |
21 |
Correct |
1 ms |
200 KB |
Output is correct |
22 |
Correct |
1 ms |
200 KB |
Output is correct |
23 |
Correct |
1 ms |
200 KB |
Output is correct |
24 |
Correct |
1 ms |
280 KB |
Output is correct |
25 |
Correct |
1 ms |
200 KB |
Output is correct |
26 |
Correct |
14 ms |
200 KB |
Output is correct |
27 |
Correct |
1 ms |
200 KB |
Output is correct |
28 |
Incorrect |
1 ms |
200 KB |
Wrong Answer [3] |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
77 ms |
284 KB |
Partially correct |
2 |
Partially correct |
101 ms |
280 KB |
Partially correct |
3 |
Partially correct |
98 ms |
284 KB |
Partially correct |
4 |
Partially correct |
90 ms |
320 KB |
Partially correct |
5 |
Partially correct |
112 ms |
284 KB |
Partially correct |
6 |
Correct |
112 ms |
288 KB |
Output is correct |
7 |
Correct |
75 ms |
200 KB |
Output is correct |
8 |
Partially correct |
77 ms |
200 KB |
Partially correct |
9 |
Incorrect |
85 ms |
284 KB |
Wrong Answer [3] |
10 |
Halted |
0 ms |
0 KB |
- |