답안 #250207

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
250207 2020-07-17T07:58:29 Z errorgorn Minerals (JOI19_minerals) C++14
75 / 100
251 ms 6320 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(chrono::system_clock::now().time_since_epoch().count());

set<int> in;
int query(int i){
	if (in.count(i)) in.erase(i);
	else in.insert(i);
	
	return Query(i);
}

int curr=0;
void rec(vector<int> v1,vector<int> v2,int flag){
	//0-in out
	//1-in in
	//2-out out
	
	/*
	for (auto &it:v1) cout<<it<<" ";cout<<endl;
	for (auto &it:v2) cout<<it<<" ";cout<<endl;
	for (auto &it:in) cout<<it<<" ";cout<<endl;
	cout<<endl;
	//*/
	
	if (sz(v1)==1){
		Answer(v1[0],v2[0]);
		
		if (flag!=2) curr=query(v1[0]);
		if (flag==1) curr=query(v2[0]);
		return;
	}
	
	vector<int> l1,l2,r1,r2;
	
	int half;
	if (flag!=2) half=sz(v1)*0.6;
	else half=ceil(sz(v1)*0.4);
	
	rep(x,0,half){
		if (flag==2) curr=query(v1[x]);
		l1.push_back(v1[x]);
	}
	rep(x,half,sz(v1)){
		if (flag!=2) curr=query(v1[x]);
		r1.push_back(v1[x]);
	}
	
	if (flag!=1){
		for (auto &it:v2){
			int temp=query(it);
			
			if (temp==curr){
				l2.push_back(it);
			}
			else{
				r2.push_back(it);
			}
			
			curr=temp;
		}
		
		rec(l1,l2,1),rec(r2,r1,0);
	}
	else{
		for (auto &it:v2){
			int temp=query(it);
				
			if (temp==curr){
				l2.push_back(it);
			}
			else{
				r2.push_back(it);
			}
			
			curr=temp;
		}
		
		rec(l1,l2,0),rec(r1,r2,2);
	}
}

 
void Solve(int n) {
	vector<int> v1,v2;
	
	rep(x,1,2*n+1){
		int temp=query(x);
		
		if (temp==curr){
			v2.push_back(x);
		}
		else{
			v1.push_back(x);
		}
		
		curr=temp;
	}
	
	rec(v1,v2,1);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 512 KB Output is correct
2 Correct 8 ms 640 KB Output is correct
3 Correct 18 ms 896 KB Output is correct
4 Correct 40 ms 1408 KB Output is correct
5 Correct 80 ms 2552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 4 ms 512 KB Output is correct
6 Correct 8 ms 640 KB Output is correct
7 Correct 18 ms 896 KB Output is correct
8 Correct 40 ms 1408 KB Output is correct
9 Correct 80 ms 2552 KB Output is correct
10 Correct 4 ms 512 KB Output is correct
11 Correct 52 ms 1792 KB Output is correct
12 Correct 82 ms 2560 KB Output is correct
13 Correct 68 ms 2560 KB Output is correct
14 Correct 65 ms 2432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 4 ms 512 KB Output is correct
6 Correct 8 ms 640 KB Output is correct
7 Correct 18 ms 896 KB Output is correct
8 Correct 40 ms 1408 KB Output is correct
9 Correct 80 ms 2552 KB Output is correct
10 Correct 4 ms 512 KB Output is correct
11 Correct 52 ms 1792 KB Output is correct
12 Correct 82 ms 2560 KB Output is correct
13 Correct 68 ms 2560 KB Output is correct
14 Correct 65 ms 2432 KB Output is correct
15 Correct 250 ms 6004 KB Output is correct
16 Correct 240 ms 5872 KB Output is correct
17 Correct 194 ms 6128 KB Output is correct
18 Correct 183 ms 5844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 4 ms 512 KB Output is correct
6 Correct 8 ms 640 KB Output is correct
7 Correct 18 ms 896 KB Output is correct
8 Correct 40 ms 1408 KB Output is correct
9 Correct 80 ms 2552 KB Output is correct
10 Correct 4 ms 512 KB Output is correct
11 Correct 52 ms 1792 KB Output is correct
12 Correct 82 ms 2560 KB Output is correct
13 Correct 68 ms 2560 KB Output is correct
14 Correct 65 ms 2432 KB Output is correct
15 Correct 250 ms 6004 KB Output is correct
16 Correct 240 ms 5872 KB Output is correct
17 Correct 194 ms 6128 KB Output is correct
18 Correct 183 ms 5844 KB Output is correct
19 Correct 247 ms 6128 KB Output is correct
20 Correct 247 ms 6132 KB Output is correct
21 Correct 198 ms 6256 KB Output is correct
22 Correct 189 ms 5876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 4 ms 512 KB Output is correct
6 Correct 8 ms 640 KB Output is correct
7 Correct 18 ms 896 KB Output is correct
8 Correct 40 ms 1408 KB Output is correct
9 Correct 80 ms 2552 KB Output is correct
10 Correct 4 ms 512 KB Output is correct
11 Correct 52 ms 1792 KB Output is correct
12 Correct 82 ms 2560 KB Output is correct
13 Correct 68 ms 2560 KB Output is correct
14 Correct 65 ms 2432 KB Output is correct
15 Correct 250 ms 6004 KB Output is correct
16 Correct 240 ms 5872 KB Output is correct
17 Correct 194 ms 6128 KB Output is correct
18 Correct 183 ms 5844 KB Output is correct
19 Correct 247 ms 6128 KB Output is correct
20 Correct 247 ms 6132 KB Output is correct
21 Correct 198 ms 6256 KB Output is correct
22 Correct 189 ms 5876 KB Output is correct
23 Incorrect 251 ms 6320 KB Wrong Answer [2]
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 4 ms 512 KB Output is correct
6 Correct 8 ms 640 KB Output is correct
7 Correct 18 ms 896 KB Output is correct
8 Correct 40 ms 1408 KB Output is correct
9 Correct 80 ms 2552 KB Output is correct
10 Correct 4 ms 512 KB Output is correct
11 Correct 52 ms 1792 KB Output is correct
12 Correct 82 ms 2560 KB Output is correct
13 Correct 68 ms 2560 KB Output is correct
14 Correct 65 ms 2432 KB Output is correct
15 Correct 250 ms 6004 KB Output is correct
16 Correct 240 ms 5872 KB Output is correct
17 Correct 194 ms 6128 KB Output is correct
18 Correct 183 ms 5844 KB Output is correct
19 Correct 247 ms 6128 KB Output is correct
20 Correct 247 ms 6132 KB Output is correct
21 Correct 198 ms 6256 KB Output is correct
22 Correct 189 ms 5876 KB Output is correct
23 Incorrect 251 ms 6320 KB Wrong Answer [2]
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 4 ms 512 KB Output is correct
6 Correct 8 ms 640 KB Output is correct
7 Correct 18 ms 896 KB Output is correct
8 Correct 40 ms 1408 KB Output is correct
9 Correct 80 ms 2552 KB Output is correct
10 Correct 4 ms 512 KB Output is correct
11 Correct 52 ms 1792 KB Output is correct
12 Correct 82 ms 2560 KB Output is correct
13 Correct 68 ms 2560 KB Output is correct
14 Correct 65 ms 2432 KB Output is correct
15 Correct 250 ms 6004 KB Output is correct
16 Correct 240 ms 5872 KB Output is correct
17 Correct 194 ms 6128 KB Output is correct
18 Correct 183 ms 5844 KB Output is correct
19 Correct 247 ms 6128 KB Output is correct
20 Correct 247 ms 6132 KB Output is correct
21 Correct 198 ms 6256 KB Output is correct
22 Correct 189 ms 5876 KB Output is correct
23 Incorrect 251 ms 6320 KB Wrong Answer [2]
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 4 ms 512 KB Output is correct
6 Correct 8 ms 640 KB Output is correct
7 Correct 18 ms 896 KB Output is correct
8 Correct 40 ms 1408 KB Output is correct
9 Correct 80 ms 2552 KB Output is correct
10 Correct 4 ms 512 KB Output is correct
11 Correct 52 ms 1792 KB Output is correct
12 Correct 82 ms 2560 KB Output is correct
13 Correct 68 ms 2560 KB Output is correct
14 Correct 65 ms 2432 KB Output is correct
15 Correct 250 ms 6004 KB Output is correct
16 Correct 240 ms 5872 KB Output is correct
17 Correct 194 ms 6128 KB Output is correct
18 Correct 183 ms 5844 KB Output is correct
19 Correct 247 ms 6128 KB Output is correct
20 Correct 247 ms 6132 KB Output is correct
21 Correct 198 ms 6256 KB Output is correct
22 Correct 189 ms 5876 KB Output is correct
23 Incorrect 251 ms 6320 KB Wrong Answer [2]
24 Halted 0 ms 0 KB -