답안 #250104

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
250104 2020-07-17T03:04:28 Z jamielim Minerals (JOI19_minerals) C++14
0 / 100
3 ms 640 KB
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define SZ(x) (int)x.size()

vector<int> u;
bool there[100000];
int ord[100000];
int ans[50000];
int prv=0;
int n;

void rec(int l,int r,vector<int> poss){
	if(l==r){ans[l]=poss[0];return;}
	//printf("%d %d %d\n",l,r,SZ(poss));
	int m=(l+r)/2;
	for(int i=0;i<l;i++)if(there[u[i]])prv=Query(u[i]);
	for(int i=m+1;i<n;i++)if(there[u[i]])prv=Query(u[i]);
	for(int i=l;i<=m;i++)if(!there[u[i]])prv=Query(u[i]);
	for(int i=1;i<=2*n;i++)if(ord[i]==2)if(there[i])prv=Query(i);
	vector<int> v1,v2;
	for(int i=0;i<SZ(poss);i++){
		int cur=Query(poss[i]);
		if(prv==cur){
			v1.pb(poss[i]);
		}else{
			prv=cur;
			v2.pb(poss[i]);
		}
	}
	//for(int i=l;i<=m;i++)printf("%d ",u[i]);printf("\n");
	//for(int i:v1)printf("%d ",i);printf("\n");
	rec(l,m,v1);rec(m+1,r,v2);
	v1.clear();v2.clear();poss.clear();
}

void Solve(int N) {
	n=N;
	vector<int> poss;
	for(int i=1;i<=2*N;i++){
		int cur=Query(i);
		if(cur>prv)prv=cur,u.pb(i),there[i]=1,ord[i]=1;
		else poss.pb(i),ord[i]=2,there[i]=1;
	}
	rec(0,N-1,poss);
	for(int i=0;i<N;i++){
		//printf("%d %d\n",u[i],ans[i]);
		Answer(u[i],ans[i]);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -