답안 #250159

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
250159 2020-07-17T05:23:50 Z errorgorn Minerals (JOI19_minerals) C++14
40 / 100
33 ms 3576 KB
#include <bits/stdc++.h>
#include "minerals.h"
using namespace std;

#define rep(x,s,e) for (auto x=s;x<e;x++)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()

mt19937 rng(42069);

void rec(vector<int> v, bool filled){
	//for (auto &it:v) cout<<it<<" ";cout<<endl;
	
	if (sz(v)==2){
		Answer(v[0],v[1]);
		
		if (filled) Query(v[0]),Query(v[1]);
		
		return;
	}
	
	int ss=1;
	while (ss<sz(v)/2) ss<<=1;
	ss>>=1;
	
	vector<int> l,r;
	if (!filled){
		for (auto &it:v){
			if (Query(it)>ss){
				r.push_back(it);
				Query(it);
			}
			else{
				l.push_back(it);
			}
		}
	}
	
	else{
		int curr=v.size()/2;
		
		vector<int> temp;
		while (curr>ss){
			curr=Query(v.back());
			temp.push_back(v.back());
			v.pop_back();
		}
		
		while (!v.empty()){
			l.push_back(v.back());
			v.pop_back();
		}
		
		for (auto &it:temp){
			if (Query(it)>ss){
				r.push_back(it);
				Query(it);
			}
			else{
				l.push_back(it);
			}
		}
	}
	
	rec(l,true),rec(r,false);
}

void Solve(int n) {
	vector<int> v;
	rep(x,1,2*n+1) v.push_back(x);
	
	rec(v,false);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 11 ms 896 KB Output is correct
5 Correct 21 ms 1428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 21 ms 1428 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 14 ms 1152 KB Output is correct
12 Correct 21 ms 1536 KB Output is correct
13 Correct 17 ms 1500 KB Output is correct
14 Correct 19 ms 1400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 21 ms 1428 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 14 ms 1152 KB Output is correct
12 Correct 21 ms 1536 KB Output is correct
13 Correct 17 ms 1500 KB Output is correct
14 Correct 19 ms 1400 KB Output is correct
15 Incorrect 33 ms 3576 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 21 ms 1428 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 14 ms 1152 KB Output is correct
12 Correct 21 ms 1536 KB Output is correct
13 Correct 17 ms 1500 KB Output is correct
14 Correct 19 ms 1400 KB Output is correct
15 Incorrect 33 ms 3576 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 21 ms 1428 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 14 ms 1152 KB Output is correct
12 Correct 21 ms 1536 KB Output is correct
13 Correct 17 ms 1500 KB Output is correct
14 Correct 19 ms 1400 KB Output is correct
15 Incorrect 33 ms 3576 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 21 ms 1428 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 14 ms 1152 KB Output is correct
12 Correct 21 ms 1536 KB Output is correct
13 Correct 17 ms 1500 KB Output is correct
14 Correct 19 ms 1400 KB Output is correct
15 Incorrect 33 ms 3576 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 21 ms 1428 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 14 ms 1152 KB Output is correct
12 Correct 21 ms 1536 KB Output is correct
13 Correct 17 ms 1500 KB Output is correct
14 Correct 19 ms 1400 KB Output is correct
15 Incorrect 33 ms 3576 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 21 ms 1428 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 14 ms 1152 KB Output is correct
12 Correct 21 ms 1536 KB Output is correct
13 Correct 17 ms 1500 KB Output is correct
14 Correct 19 ms 1400 KB Output is correct
15 Incorrect 33 ms 3576 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -