답안 #1061214

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1061214 2024-08-16T07:17:34 Z ttamx Monster Game (JOI21_monster) C++17
0 / 100
62 ms 600 KB
#include "monster.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> Solve(int n){
	vector<int> a(n),b(n);
	function<void(int,int)> msort=[&](int l,int r){
		if(l==r)return;
		int m=(l+r)/2;
		msort(l,m);
		msort(m+1,r);
		for(int i=l,j=m+1,p=l;p<=r;p++){
			if(j>r||(i<=m&&!Query(a[i],a[j]))){
				b[p]=a[i++];
			}else{
				b[p]=a[j++];
			}
		}
		for(int i=l;i<=r;i++)a[i]=b[i];
	};
	iota(a.begin(),a.end(),0);
	msort(0,n-1);
	int st=-1;
	if(Query(a[1],a[0])){
		st=1;
		for(int i=2;i<n;i++){
			if(Query(a[1],a[i])){
				st=-1;
				break;
			}
		}
	}
	if(st==-1){
		st=2;
		while(Query(a[st],a[st-1])||Query(a[st-2],a[st])){
			st++;
			assert(st<n);
		}
	}
	reverse(a.begin(),a.begin()+st+1);
	for(int i=st+1;i<n;i++){
		int j=i;
		while(!Query(a[i-1],a[j])){
			j++;
			assert(j<n);
		}
		reverse(a.begin()+i,a.begin()+j+1);
		i=j;
	}
	vector<int> ans(n);
	for(int i=0;i<n;i++)ans[a[i]]=i;
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 52 ms 344 KB Partially correct
2 Partially correct 57 ms 416 KB Partially correct
3 Partially correct 51 ms 424 KB Partially correct
4 Partially correct 47 ms 420 KB Partially correct
5 Partially correct 49 ms 416 KB Partially correct
6 Correct 29 ms 344 KB Output is correct
7 Correct 50 ms 344 KB Output is correct
8 Partially correct 53 ms 344 KB Partially correct
9 Runtime error 62 ms 424 KB Execution killed with signal 6
10 Halted 0 ms 0 KB -