답안 #706203

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
706203 2023-03-06T04:40:47 Z alvingogo Minerals (JOI19_minerals) C++14
90 / 100
70 ms 2816 KB
#include <bits/stdc++.h>
#include "minerals.h"
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define p_q priority_queue
using namespace std;

/* Mineral:
i can only figure out that merge sort might be a useful idea

but it is 3/2 * n * log(n) = 1.5 * 43000 * 15 = 2.25 * 43000 = oh wow, i can't math

so the first thing is to find out n minerals which satisfies that no two minerals share the same type

which can be done in n steps

after that, we can merge sort it
let the two parts be X, Y, both have size n
1. put the first n/2 numbers in x to set
2. put every numbers in Y to set, check the answer being changed
3. for every numbers in Y which not causes the answer changed, pop out it from the set
4. go to the next two parts
it's 2*n?
no, for the next level, for one part we can see it as we have done the first step to Y
and for another we just think it the same

so let's go!!

3/2 * 43000 * 15 = 967500
1031500


the recursive function might code in this way:
f(X,Y,flag)
which flag = 0 -> we should do the first step
flag = 1 -> we shouldn't do

and oh, to find out if the correspond is in the first step 
we can check if Query() is same to the original answer

done!

*/

int ans=0;

mt19937 rnd(time(NULL));
void f(vector<int>& x,vector<int>& y,int flag){
	int n=x.size();
	shuffle(x.begin(),x.end(),rnd);
	shuffle(y.begin(),y.end(),rnd);
	if(n==1){
		Answer(x[0],y[0]);
		return;
	}
	vector<int> a,b,c,d;
	int p=n/2,q=n-p;
	for(int i=0;i<n/2;i++){
		ans=Query(x[i]);
	}
	for(int i=0;i<n/2;i++){
		a.push_back(x[i]);
	}
	for(int i=n/2;i<n;i++){
		b.push_back(x[i]);
	}
	for(int i=0;i<n;i++){
		if(p==0){
			q--;
			d.push_back(y[i]);
			continue;
		}
		if(q==0){
			p--;
			c.push_back(y[i]);
			continue;
		}
		int e=Query(y[i]);
		if((e==ans) xor flag){
			c.push_back(y[i]);
			p--;
		}
		else{
			d.push_back(y[i]);
			q--;
		}
		ans=e;
	}
	f(a,c,flag^1);
	f(b,d,flag);
}
void Solve(int n){
	vector<int> x,y;
	int a=n,b=n;
	for(int i=1;i<=2*n;i++){
		int z=Query(i);
		if(a==0){
			y.push_back(i);
			continue;
		}
		if(ans!=z){
			x.push_back(i);
		}
		else{
			y.push_back(i);
		}
		ans=z;
	}
	shuffle(x.begin(),x.end(),rnd);
	shuffle(y.begin(),y.end(),rnd);
	f(x,y,1);
}

Compilation message

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:96:10: warning: unused variable 'b' [-Wunused-variable]
   96 |  int a=n,b=n;
      |          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 368 KB Output is correct
2 Correct 3 ms 336 KB Output is correct
3 Correct 5 ms 524 KB Output is correct
4 Correct 11 ms 628 KB Output is correct
5 Correct 23 ms 1084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 368 KB Output is correct
6 Correct 3 ms 336 KB Output is correct
7 Correct 5 ms 524 KB Output is correct
8 Correct 11 ms 628 KB Output is correct
9 Correct 23 ms 1084 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 14 ms 956 KB Output is correct
12 Correct 21 ms 1052 KB Output is correct
13 Correct 20 ms 1168 KB Output is correct
14 Correct 19 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 368 KB Output is correct
6 Correct 3 ms 336 KB Output is correct
7 Correct 5 ms 524 KB Output is correct
8 Correct 11 ms 628 KB Output is correct
9 Correct 23 ms 1084 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 14 ms 956 KB Output is correct
12 Correct 21 ms 1052 KB Output is correct
13 Correct 20 ms 1168 KB Output is correct
14 Correct 19 ms 1108 KB Output is correct
15 Correct 62 ms 2540 KB Output is correct
16 Correct 58 ms 2564 KB Output is correct
17 Correct 65 ms 2572 KB Output is correct
18 Correct 54 ms 2376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 368 KB Output is correct
6 Correct 3 ms 336 KB Output is correct
7 Correct 5 ms 524 KB Output is correct
8 Correct 11 ms 628 KB Output is correct
9 Correct 23 ms 1084 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 14 ms 956 KB Output is correct
12 Correct 21 ms 1052 KB Output is correct
13 Correct 20 ms 1168 KB Output is correct
14 Correct 19 ms 1108 KB Output is correct
15 Correct 62 ms 2540 KB Output is correct
16 Correct 58 ms 2564 KB Output is correct
17 Correct 65 ms 2572 KB Output is correct
18 Correct 54 ms 2376 KB Output is correct
19 Correct 58 ms 2612 KB Output is correct
20 Correct 59 ms 2612 KB Output is correct
21 Correct 58 ms 2556 KB Output is correct
22 Correct 58 ms 2492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 368 KB Output is correct
6 Correct 3 ms 336 KB Output is correct
7 Correct 5 ms 524 KB Output is correct
8 Correct 11 ms 628 KB Output is correct
9 Correct 23 ms 1084 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 14 ms 956 KB Output is correct
12 Correct 21 ms 1052 KB Output is correct
13 Correct 20 ms 1168 KB Output is correct
14 Correct 19 ms 1108 KB Output is correct
15 Correct 62 ms 2540 KB Output is correct
16 Correct 58 ms 2564 KB Output is correct
17 Correct 65 ms 2572 KB Output is correct
18 Correct 54 ms 2376 KB Output is correct
19 Correct 58 ms 2612 KB Output is correct
20 Correct 59 ms 2612 KB Output is correct
21 Correct 58 ms 2556 KB Output is correct
22 Correct 58 ms 2492 KB Output is correct
23 Correct 65 ms 2816 KB Output is correct
24 Correct 59 ms 2656 KB Output is correct
25 Correct 63 ms 2692 KB Output is correct
26 Correct 59 ms 2496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 368 KB Output is correct
6 Correct 3 ms 336 KB Output is correct
7 Correct 5 ms 524 KB Output is correct
8 Correct 11 ms 628 KB Output is correct
9 Correct 23 ms 1084 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 14 ms 956 KB Output is correct
12 Correct 21 ms 1052 KB Output is correct
13 Correct 20 ms 1168 KB Output is correct
14 Correct 19 ms 1108 KB Output is correct
15 Correct 62 ms 2540 KB Output is correct
16 Correct 58 ms 2564 KB Output is correct
17 Correct 65 ms 2572 KB Output is correct
18 Correct 54 ms 2376 KB Output is correct
19 Correct 58 ms 2612 KB Output is correct
20 Correct 59 ms 2612 KB Output is correct
21 Correct 58 ms 2556 KB Output is correct
22 Correct 58 ms 2492 KB Output is correct
23 Correct 65 ms 2816 KB Output is correct
24 Correct 59 ms 2656 KB Output is correct
25 Correct 63 ms 2692 KB Output is correct
26 Correct 59 ms 2496 KB Output is correct
27 Correct 60 ms 2760 KB Output is correct
28 Correct 64 ms 2696 KB Output is correct
29 Correct 59 ms 2760 KB Output is correct
30 Correct 63 ms 2516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 368 KB Output is correct
6 Correct 3 ms 336 KB Output is correct
7 Correct 5 ms 524 KB Output is correct
8 Correct 11 ms 628 KB Output is correct
9 Correct 23 ms 1084 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 14 ms 956 KB Output is correct
12 Correct 21 ms 1052 KB Output is correct
13 Correct 20 ms 1168 KB Output is correct
14 Correct 19 ms 1108 KB Output is correct
15 Correct 62 ms 2540 KB Output is correct
16 Correct 58 ms 2564 KB Output is correct
17 Correct 65 ms 2572 KB Output is correct
18 Correct 54 ms 2376 KB Output is correct
19 Correct 58 ms 2612 KB Output is correct
20 Correct 59 ms 2612 KB Output is correct
21 Correct 58 ms 2556 KB Output is correct
22 Correct 58 ms 2492 KB Output is correct
23 Correct 65 ms 2816 KB Output is correct
24 Correct 59 ms 2656 KB Output is correct
25 Correct 63 ms 2692 KB Output is correct
26 Correct 59 ms 2496 KB Output is correct
27 Correct 60 ms 2760 KB Output is correct
28 Correct 64 ms 2696 KB Output is correct
29 Correct 59 ms 2760 KB Output is correct
30 Correct 63 ms 2516 KB Output is correct
31 Correct 70 ms 2752 KB Output is correct
32 Correct 65 ms 2796 KB Output is correct
33 Correct 66 ms 2760 KB Output is correct
34 Correct 62 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 368 KB Output is correct
6 Correct 3 ms 336 KB Output is correct
7 Correct 5 ms 524 KB Output is correct
8 Correct 11 ms 628 KB Output is correct
9 Correct 23 ms 1084 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 14 ms 956 KB Output is correct
12 Correct 21 ms 1052 KB Output is correct
13 Correct 20 ms 1168 KB Output is correct
14 Correct 19 ms 1108 KB Output is correct
15 Correct 62 ms 2540 KB Output is correct
16 Correct 58 ms 2564 KB Output is correct
17 Correct 65 ms 2572 KB Output is correct
18 Correct 54 ms 2376 KB Output is correct
19 Correct 58 ms 2612 KB Output is correct
20 Correct 59 ms 2612 KB Output is correct
21 Correct 58 ms 2556 KB Output is correct
22 Correct 58 ms 2492 KB Output is correct
23 Correct 65 ms 2816 KB Output is correct
24 Correct 59 ms 2656 KB Output is correct
25 Correct 63 ms 2692 KB Output is correct
26 Correct 59 ms 2496 KB Output is correct
27 Correct 60 ms 2760 KB Output is correct
28 Correct 64 ms 2696 KB Output is correct
29 Correct 59 ms 2760 KB Output is correct
30 Correct 63 ms 2516 KB Output is correct
31 Correct 70 ms 2752 KB Output is correct
32 Correct 65 ms 2796 KB Output is correct
33 Correct 66 ms 2760 KB Output is correct
34 Correct 62 ms 2644 KB Output is correct
35 Incorrect 66 ms 2812 KB Wrong Answer [2]
36 Halted 0 ms 0 KB -