Submission #120644

# Submission time Handle Problem Language Result Execution time Memory
120644 2019-06-25T06:55:34 Z 김세빈(#2958) Minerals (JOI19_minerals) C++14
100 / 100
67 ms 3112 KB
#include <bits/stdc++.h>

#include "minerals.h"

using namespace std;

bool chk[101010];
int pv, nx;

int query(int x)
{
	nx = Query(x);
	if(pv != nx){
		pv = nx;
		return 1;
	}
	return 0;
}

void dnc(vector <int> &X, vector <int> &Y, bool f)
{
	if(X.size() == 1){
		Answer(X[0], Y[0]);
		return;
	}
	
	vector <int> XL, XR, YL, YR;
	int n, m, i;
	
	n = X.size();
	if(n < 10) m = n / 2;
	else if(f) m = (int)(n * 0.6);
	else m = (int)(n * 0.4);
	
	for(i=0; i<m; i++){
		XL.push_back(X[i]);
		if(!f) query(X[i]);
	}
	
	for(; i<n; i++){
		XR.push_back(X[i]);
		if(f) query(X[i]);
	}
	
	for(i=0; i<n; i++){
		if(query(Y[i])) YR.push_back(Y[i]);
		else YL.push_back(Y[i]);
		if(YL.size() == XL.size()) break;
		if(YR.size() == XR.size()) break;
	}
	
	if(YL.size() == XL.size()){
		for(i++; i<n; i++) YR.push_back(Y[i]);
	}
	else{
		for(i++; i<n; i++) YL.push_back(Y[i]);
	}
	
	dnc(XL, YL, 1); dnc(XR, YR, 0);
}

void Solve(int n)
{
	vector <int> X, Y;
	int i;
	
	for(i=1; i<=n+n; i++){
		if(query(i)) X.push_back(i);
		else Y.push_back(i);
	}
	
	dnc(X, Y, 1);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 304 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 304 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 9 ms 896 KB Output is correct
5 Correct 16 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 304 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 304 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 16 ms 1152 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 12 ms 896 KB Output is correct
12 Correct 18 ms 1192 KB Output is correct
13 Correct 14 ms 1212 KB Output is correct
14 Correct 14 ms 1244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 304 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 304 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 16 ms 1152 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 12 ms 896 KB Output is correct
12 Correct 18 ms 1192 KB Output is correct
13 Correct 14 ms 1212 KB Output is correct
14 Correct 14 ms 1244 KB Output is correct
15 Correct 43 ms 2804 KB Output is correct
16 Correct 44 ms 2824 KB Output is correct
17 Correct 30 ms 2584 KB Output is correct
18 Correct 31 ms 2448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 304 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 304 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 16 ms 1152 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 12 ms 896 KB Output is correct
12 Correct 18 ms 1192 KB Output is correct
13 Correct 14 ms 1212 KB Output is correct
14 Correct 14 ms 1244 KB Output is correct
15 Correct 43 ms 2804 KB Output is correct
16 Correct 44 ms 2824 KB Output is correct
17 Correct 30 ms 2584 KB Output is correct
18 Correct 31 ms 2448 KB Output is correct
19 Correct 44 ms 2724 KB Output is correct
20 Correct 42 ms 2676 KB Output is correct
21 Correct 32 ms 2572 KB Output is correct
22 Correct 32 ms 2504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 304 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 304 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 16 ms 1152 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 12 ms 896 KB Output is correct
12 Correct 18 ms 1192 KB Output is correct
13 Correct 14 ms 1212 KB Output is correct
14 Correct 14 ms 1244 KB Output is correct
15 Correct 43 ms 2804 KB Output is correct
16 Correct 44 ms 2824 KB Output is correct
17 Correct 30 ms 2584 KB Output is correct
18 Correct 31 ms 2448 KB Output is correct
19 Correct 44 ms 2724 KB Output is correct
20 Correct 42 ms 2676 KB Output is correct
21 Correct 32 ms 2572 KB Output is correct
22 Correct 32 ms 2504 KB Output is correct
23 Correct 45 ms 2744 KB Output is correct
24 Correct 46 ms 2856 KB Output is correct
25 Correct 34 ms 2588 KB Output is correct
26 Correct 34 ms 2508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 304 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 304 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 16 ms 1152 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 12 ms 896 KB Output is correct
12 Correct 18 ms 1192 KB Output is correct
13 Correct 14 ms 1212 KB Output is correct
14 Correct 14 ms 1244 KB Output is correct
15 Correct 43 ms 2804 KB Output is correct
16 Correct 44 ms 2824 KB Output is correct
17 Correct 30 ms 2584 KB Output is correct
18 Correct 31 ms 2448 KB Output is correct
19 Correct 44 ms 2724 KB Output is correct
20 Correct 42 ms 2676 KB Output is correct
21 Correct 32 ms 2572 KB Output is correct
22 Correct 32 ms 2504 KB Output is correct
23 Correct 45 ms 2744 KB Output is correct
24 Correct 46 ms 2856 KB Output is correct
25 Correct 34 ms 2588 KB Output is correct
26 Correct 34 ms 2508 KB Output is correct
27 Correct 47 ms 2804 KB Output is correct
28 Correct 48 ms 2808 KB Output is correct
29 Correct 35 ms 2604 KB Output is correct
30 Correct 67 ms 2556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 304 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 304 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 16 ms 1152 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 12 ms 896 KB Output is correct
12 Correct 18 ms 1192 KB Output is correct
13 Correct 14 ms 1212 KB Output is correct
14 Correct 14 ms 1244 KB Output is correct
15 Correct 43 ms 2804 KB Output is correct
16 Correct 44 ms 2824 KB Output is correct
17 Correct 30 ms 2584 KB Output is correct
18 Correct 31 ms 2448 KB Output is correct
19 Correct 44 ms 2724 KB Output is correct
20 Correct 42 ms 2676 KB Output is correct
21 Correct 32 ms 2572 KB Output is correct
22 Correct 32 ms 2504 KB Output is correct
23 Correct 45 ms 2744 KB Output is correct
24 Correct 46 ms 2856 KB Output is correct
25 Correct 34 ms 2588 KB Output is correct
26 Correct 34 ms 2508 KB Output is correct
27 Correct 47 ms 2804 KB Output is correct
28 Correct 48 ms 2808 KB Output is correct
29 Correct 35 ms 2604 KB Output is correct
30 Correct 67 ms 2556 KB Output is correct
31 Correct 48 ms 2944 KB Output is correct
32 Correct 47 ms 2932 KB Output is correct
33 Correct 34 ms 2744 KB Output is correct
34 Correct 36 ms 2532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 304 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 304 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 9 ms 896 KB Output is correct
9 Correct 16 ms 1152 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 12 ms 896 KB Output is correct
12 Correct 18 ms 1192 KB Output is correct
13 Correct 14 ms 1212 KB Output is correct
14 Correct 14 ms 1244 KB Output is correct
15 Correct 43 ms 2804 KB Output is correct
16 Correct 44 ms 2824 KB Output is correct
17 Correct 30 ms 2584 KB Output is correct
18 Correct 31 ms 2448 KB Output is correct
19 Correct 44 ms 2724 KB Output is correct
20 Correct 42 ms 2676 KB Output is correct
21 Correct 32 ms 2572 KB Output is correct
22 Correct 32 ms 2504 KB Output is correct
23 Correct 45 ms 2744 KB Output is correct
24 Correct 46 ms 2856 KB Output is correct
25 Correct 34 ms 2588 KB Output is correct
26 Correct 34 ms 2508 KB Output is correct
27 Correct 47 ms 2804 KB Output is correct
28 Correct 48 ms 2808 KB Output is correct
29 Correct 35 ms 2604 KB Output is correct
30 Correct 67 ms 2556 KB Output is correct
31 Correct 48 ms 2944 KB Output is correct
32 Correct 47 ms 2932 KB Output is correct
33 Correct 34 ms 2744 KB Output is correct
34 Correct 36 ms 2532 KB Output is correct
35 Correct 50 ms 2948 KB Output is correct
36 Correct 50 ms 3112 KB Output is correct
37 Correct 35 ms 2788 KB Output is correct
38 Correct 35 ms 2648 KB Output is correct