답안 #120709

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
120709 2019-06-25T09:49:41 Z imyujin Minerals (JOI19_minerals) C++14
100 / 100
50 ms 3708 KB
#include "minerals.h"
#include<vector>
#include<map>

using namespace std;

#define MAXN 43005

int q[2*MAXN];
vector<int> L, R;
vector<bool> chk;

vector<int> f(vector<int> lidx, int rs, int re, bool in){
	//printf("[%d %d]", rs, re);
	//for(auto a:lidx) printf("%d ", a);
	//printf("\n");
	if(rs==re) return lidx;
	int m=(int)(rs+(double)(re-rs)*0.62);
	vector<int> q(re-rs+2), lef, rig;
	for(int i=m+1; i<=re; i++) q[re-rs+1]=Query(R[i]);
	for(int i=re-rs; i>0; i--){
		q[i]=Query(L[lidx[i]]);
		if(in){
			if(q[i]!=q[i+1]) rig.push_back(lidx[i]);
			else lef.push_back(lidx[i]);
		}
		else{
			if(q[i]!=q[i+1]) lef.push_back(lidx[i]);
			else rig.push_back(lidx[i]);
		}
	}
	if(lef.size()<m-rs+1) lef.push_back(lidx[0]);
	else rig.push_back(lidx[0]);
	vector<int> v1, v2;
	v1=f(lef, rs, m, in);
	v2=f(rig, m+1, re, !in);
	for(auto a:v2) v1.push_back(a);
	return v1;
}

void Solve(int N) {
	for(int i=1; i<=2*N; i++) chk.push_back(false);
	for(int i=1; i<=2*N; i++){
		q[i]=Query(i);
		if(q[i]>q[i-1]) L.push_back(i);
		else R.push_back(i);
	}
	//for(auto a:L) printf("%d ", a);
	//printf("\n");
	vector<int> v(N);
	for(int i=0; i<N; i++) v[i]=i;
	vector<int> ans=f(v, 0, N-1, true);
	//for(auto a:ans) printf("{%d}", a);
	for(int i=0; i<N; i++) Answer(L[ans[i]], R[i]);
}

Compilation message

minerals.cpp: In function 'std::vector<int> f(std::vector<int>, int, int, bool)':
minerals.cpp:32:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(lef.size()<m-rs+1) lef.push_back(lidx[0]);
     ~~~~~~~~~~^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 9 ms 896 KB Output is correct
5 Correct 16 ms 1664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 16 ms 1664 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 12 ms 1280 KB Output is correct
12 Correct 16 ms 1528 KB Output is correct
13 Correct 13 ms 1664 KB Output is correct
14 Correct 13 ms 1664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 16 ms 1664 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 12 ms 1280 KB Output is correct
12 Correct 16 ms 1528 KB Output is correct
13 Correct 13 ms 1664 KB Output is correct
14 Correct 13 ms 1664 KB Output is correct
15 Correct 42 ms 3212 KB Output is correct
16 Correct 44 ms 3204 KB Output is correct
17 Correct 33 ms 3280 KB Output is correct
18 Correct 38 ms 3124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 16 ms 1664 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 12 ms 1280 KB Output is correct
12 Correct 16 ms 1528 KB Output is correct
13 Correct 13 ms 1664 KB Output is correct
14 Correct 13 ms 1664 KB Output is correct
15 Correct 42 ms 3212 KB Output is correct
16 Correct 44 ms 3204 KB Output is correct
17 Correct 33 ms 3280 KB Output is correct
18 Correct 38 ms 3124 KB Output is correct
19 Correct 44 ms 3316 KB Output is correct
20 Correct 47 ms 3460 KB Output is correct
21 Correct 33 ms 3300 KB Output is correct
22 Correct 34 ms 3124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 16 ms 1664 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 12 ms 1280 KB Output is correct
12 Correct 16 ms 1528 KB Output is correct
13 Correct 13 ms 1664 KB Output is correct
14 Correct 13 ms 1664 KB Output is correct
15 Correct 42 ms 3212 KB Output is correct
16 Correct 44 ms 3204 KB Output is correct
17 Correct 33 ms 3280 KB Output is correct
18 Correct 38 ms 3124 KB Output is correct
19 Correct 44 ms 3316 KB Output is correct
20 Correct 47 ms 3460 KB Output is correct
21 Correct 33 ms 3300 KB Output is correct
22 Correct 34 ms 3124 KB Output is correct
23 Correct 45 ms 3444 KB Output is correct
24 Correct 46 ms 3360 KB Output is correct
25 Correct 33 ms 3312 KB Output is correct
26 Correct 34 ms 3252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 16 ms 1664 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 12 ms 1280 KB Output is correct
12 Correct 16 ms 1528 KB Output is correct
13 Correct 13 ms 1664 KB Output is correct
14 Correct 13 ms 1664 KB Output is correct
15 Correct 42 ms 3212 KB Output is correct
16 Correct 44 ms 3204 KB Output is correct
17 Correct 33 ms 3280 KB Output is correct
18 Correct 38 ms 3124 KB Output is correct
19 Correct 44 ms 3316 KB Output is correct
20 Correct 47 ms 3460 KB Output is correct
21 Correct 33 ms 3300 KB Output is correct
22 Correct 34 ms 3124 KB Output is correct
23 Correct 45 ms 3444 KB Output is correct
24 Correct 46 ms 3360 KB Output is correct
25 Correct 33 ms 3312 KB Output is correct
26 Correct 34 ms 3252 KB Output is correct
27 Correct 45 ms 3456 KB Output is correct
28 Correct 45 ms 3460 KB Output is correct
29 Correct 35 ms 3404 KB Output is correct
30 Correct 34 ms 3332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 16 ms 1664 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 12 ms 1280 KB Output is correct
12 Correct 16 ms 1528 KB Output is correct
13 Correct 13 ms 1664 KB Output is correct
14 Correct 13 ms 1664 KB Output is correct
15 Correct 42 ms 3212 KB Output is correct
16 Correct 44 ms 3204 KB Output is correct
17 Correct 33 ms 3280 KB Output is correct
18 Correct 38 ms 3124 KB Output is correct
19 Correct 44 ms 3316 KB Output is correct
20 Correct 47 ms 3460 KB Output is correct
21 Correct 33 ms 3300 KB Output is correct
22 Correct 34 ms 3124 KB Output is correct
23 Correct 45 ms 3444 KB Output is correct
24 Correct 46 ms 3360 KB Output is correct
25 Correct 33 ms 3312 KB Output is correct
26 Correct 34 ms 3252 KB Output is correct
27 Correct 45 ms 3456 KB Output is correct
28 Correct 45 ms 3460 KB Output is correct
29 Correct 35 ms 3404 KB Output is correct
30 Correct 34 ms 3332 KB Output is correct
31 Correct 48 ms 3508 KB Output is correct
32 Correct 47 ms 3460 KB Output is correct
33 Correct 36 ms 3708 KB Output is correct
34 Correct 36 ms 3332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 16 ms 1664 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 12 ms 1280 KB Output is correct
12 Correct 16 ms 1528 KB Output is correct
13 Correct 13 ms 1664 KB Output is correct
14 Correct 13 ms 1664 KB Output is correct
15 Correct 42 ms 3212 KB Output is correct
16 Correct 44 ms 3204 KB Output is correct
17 Correct 33 ms 3280 KB Output is correct
18 Correct 38 ms 3124 KB Output is correct
19 Correct 44 ms 3316 KB Output is correct
20 Correct 47 ms 3460 KB Output is correct
21 Correct 33 ms 3300 KB Output is correct
22 Correct 34 ms 3124 KB Output is correct
23 Correct 45 ms 3444 KB Output is correct
24 Correct 46 ms 3360 KB Output is correct
25 Correct 33 ms 3312 KB Output is correct
26 Correct 34 ms 3252 KB Output is correct
27 Correct 45 ms 3456 KB Output is correct
28 Correct 45 ms 3460 KB Output is correct
29 Correct 35 ms 3404 KB Output is correct
30 Correct 34 ms 3332 KB Output is correct
31 Correct 48 ms 3508 KB Output is correct
32 Correct 47 ms 3460 KB Output is correct
33 Correct 36 ms 3708 KB Output is correct
34 Correct 36 ms 3332 KB Output is correct
35 Correct 49 ms 3596 KB Output is correct
36 Correct 50 ms 3636 KB Output is correct
37 Correct 36 ms 3660 KB Output is correct
38 Correct 37 ms 3460 KB Output is correct