답안 #901328

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
901328 2024-01-09T10:42:05 Z Darren0724 Minerals (JOI19_minerals) C++17
75 / 100
30 ms 3572 KB
#include "minerals.h"
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
//Query(int)
//Answer(int,int)
mt19937 rnd(time(0));
int last=0;
int ask(int k){
	int p = Query(k);
	int tmp = p - last;
	last = p;
	return tmp; 
}
void dc(vector<int> &a,vector<int> &b,int t){
	int n=a.size();
	if(n==1){
		Answer(a[0],b[0]);
		return;
	}
	int r=__lg(n-1);
	int m=1<<r;
	if(t>0){
		m=max(m,n-m);
		for(int i=m;i<n;i++){
			ask(a[i]);
		}
	}
	else{
		m=min(m,n-m);
		for(int i=0;i<m;i++){
			ask(a[i]);
		}
	}
	vector<int> a1,a2,b1,b2;
	for(int i=0;i<m;i++){
		a1.push_back(a[i]);
	}
	for(int i=m;i<n;i++){
		a2.push_back(a[i]);
	}
	for(int i=0;i<n;i++){
		if(ask(b[i])==0){
			b1.push_back(b[i]);
		}
		else{
			b2.push_back(b[i]);
		}
	}
	if(t==0){
		dc(a1,b1,2);
		dc(b2,a2,1);
	}
	if(t==1){
		dc(a1,b1,2);
		dc(b2,a2,1);
	}
	if(t==2){
		dc(a1,b1,1);
		dc(a2,b2,0);
	}	
}
void Solve(int n) {
	vector<int> a,b;
	vector<int> t(n*2);
	iota(t.begin(),t.end(),1);
	shuffle(t.begin(),t.end(),rnd);
	for(int j=0;j<n*2;j++){
		int i=t[j];
		if(ask(i)==0){
			b.push_back(i);
		}
		else{
			a.push_back(i);
		}
	}
	dc(a,b,2);
}
/*
times: N*2 + N log N * 3/2
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 2 ms 600 KB Output is correct
4 Correct 5 ms 856 KB Output is correct
5 Correct 9 ms 1404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 5 ms 856 KB Output is correct
9 Correct 9 ms 1404 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 6 ms 1032 KB Output is correct
12 Correct 9 ms 1368 KB Output is correct
13 Correct 11 ms 1300 KB Output is correct
14 Correct 9 ms 1368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 5 ms 856 KB Output is correct
9 Correct 9 ms 1404 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 6 ms 1032 KB Output is correct
12 Correct 9 ms 1368 KB Output is correct
13 Correct 11 ms 1300 KB Output is correct
14 Correct 9 ms 1368 KB Output is correct
15 Correct 26 ms 2980 KB Output is correct
16 Correct 28 ms 3148 KB Output is correct
17 Correct 25 ms 3000 KB Output is correct
18 Correct 25 ms 3172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 5 ms 856 KB Output is correct
9 Correct 9 ms 1404 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 6 ms 1032 KB Output is correct
12 Correct 9 ms 1368 KB Output is correct
13 Correct 11 ms 1300 KB Output is correct
14 Correct 9 ms 1368 KB Output is correct
15 Correct 26 ms 2980 KB Output is correct
16 Correct 28 ms 3148 KB Output is correct
17 Correct 25 ms 3000 KB Output is correct
18 Correct 25 ms 3172 KB Output is correct
19 Correct 27 ms 3052 KB Output is correct
20 Correct 30 ms 2904 KB Output is correct
21 Correct 26 ms 3572 KB Output is correct
22 Correct 27 ms 2896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 5 ms 856 KB Output is correct
9 Correct 9 ms 1404 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 6 ms 1032 KB Output is correct
12 Correct 9 ms 1368 KB Output is correct
13 Correct 11 ms 1300 KB Output is correct
14 Correct 9 ms 1368 KB Output is correct
15 Correct 26 ms 2980 KB Output is correct
16 Correct 28 ms 3148 KB Output is correct
17 Correct 25 ms 3000 KB Output is correct
18 Correct 25 ms 3172 KB Output is correct
19 Correct 27 ms 3052 KB Output is correct
20 Correct 30 ms 2904 KB Output is correct
21 Correct 26 ms 3572 KB Output is correct
22 Correct 27 ms 2896 KB Output is correct
23 Incorrect 27 ms 3056 KB Wrong Answer [2]
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 5 ms 856 KB Output is correct
9 Correct 9 ms 1404 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 6 ms 1032 KB Output is correct
12 Correct 9 ms 1368 KB Output is correct
13 Correct 11 ms 1300 KB Output is correct
14 Correct 9 ms 1368 KB Output is correct
15 Correct 26 ms 2980 KB Output is correct
16 Correct 28 ms 3148 KB Output is correct
17 Correct 25 ms 3000 KB Output is correct
18 Correct 25 ms 3172 KB Output is correct
19 Correct 27 ms 3052 KB Output is correct
20 Correct 30 ms 2904 KB Output is correct
21 Correct 26 ms 3572 KB Output is correct
22 Correct 27 ms 2896 KB Output is correct
23 Incorrect 27 ms 3056 KB Wrong Answer [2]
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 5 ms 856 KB Output is correct
9 Correct 9 ms 1404 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 6 ms 1032 KB Output is correct
12 Correct 9 ms 1368 KB Output is correct
13 Correct 11 ms 1300 KB Output is correct
14 Correct 9 ms 1368 KB Output is correct
15 Correct 26 ms 2980 KB Output is correct
16 Correct 28 ms 3148 KB Output is correct
17 Correct 25 ms 3000 KB Output is correct
18 Correct 25 ms 3172 KB Output is correct
19 Correct 27 ms 3052 KB Output is correct
20 Correct 30 ms 2904 KB Output is correct
21 Correct 26 ms 3572 KB Output is correct
22 Correct 27 ms 2896 KB Output is correct
23 Incorrect 27 ms 3056 KB Wrong Answer [2]
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 5 ms 856 KB Output is correct
9 Correct 9 ms 1404 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 6 ms 1032 KB Output is correct
12 Correct 9 ms 1368 KB Output is correct
13 Correct 11 ms 1300 KB Output is correct
14 Correct 9 ms 1368 KB Output is correct
15 Correct 26 ms 2980 KB Output is correct
16 Correct 28 ms 3148 KB Output is correct
17 Correct 25 ms 3000 KB Output is correct
18 Correct 25 ms 3172 KB Output is correct
19 Correct 27 ms 3052 KB Output is correct
20 Correct 30 ms 2904 KB Output is correct
21 Correct 26 ms 3572 KB Output is correct
22 Correct 27 ms 2896 KB Output is correct
23 Incorrect 27 ms 3056 KB Wrong Answer [2]
24 Halted 0 ms 0 KB -