답안 #250503

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
250503 2020-07-18T08:37:40 Z lyc Minerals (JOI19_minerals) C++14
80 / 100
63 ms 3128 KB
#include "minerals.h"
#include <bits/stdc++.h>

#define TRACE(x) std::cerr << #x << " :: " << x << std::endl
#define _ << " " <<
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for (int i=(a);i>=(b);--i)

const int mxN = 43005;

int inside[2*mxN];
int curVal, curAns;

int Add(int i) {
	if (!inside[i]) {
		inside[i] = true;
		curVal = Query(i);
	}
	return curVal;
}

int Del(int i) {
	if (inside[i]) {
		inside[i] = false;
		curVal = Query(i);
	}
	return curVal;
}

void Ans(int a, int b) { Answer(a,b); ++curAns; }

void rec(std::vector<int>& a, std::vector<int>& b) {
	//~ for (int x : a) std::cout << x << ' ';
	//~ std::cout << "| ";
	//~ for (int x : b) std::cout << x << ' ';
	//~ std::cout << std::endl;
	
	if (SZ(a) == 1) { Ans(a[0],b[0]); return; }
	
	int m = (SZ(a)-1)/2;
	std::vector<int> ax, ay, bx, by;
	FOR(i,0,m){
		ax.push_back(a[i]);
		Add(a[i]);
	}
	FOR(i,m+1,SZ(a)-1){
		ay.push_back(a[i]);
		Del(a[i]);
	}
	
	for (int& e : b) {
		int r = curVal;
		if (SZ(by) == SZ(ay) || (inside[e] ? Del(e) : Add(e)) == r) bx.push_back(e);
		else by.push_back(e);
	}
	
	rec(ax,bx);
	rec(ay,by);
}

void Solve(int N) {
	std::vector<int> a, b;
	
	int r = 0;
	FOR(i,1,2*N){
		int s = Add(i);
		if (s > r) a.push_back(i), r = s;
		else b.push_back(i);
	}
	
	rec(a,b);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 384 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 10 ms 768 KB Output is correct
5 Correct 19 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 384 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 10 ms 768 KB Output is correct
9 Correct 19 ms 1280 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 13 ms 1024 KB Output is correct
12 Correct 19 ms 1280 KB Output is correct
13 Correct 16 ms 1280 KB Output is correct
14 Correct 15 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 384 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 10 ms 768 KB Output is correct
9 Correct 19 ms 1280 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 13 ms 1024 KB Output is correct
12 Correct 19 ms 1280 KB Output is correct
13 Correct 16 ms 1280 KB Output is correct
14 Correct 15 ms 1280 KB Output is correct
15 Correct 58 ms 2976 KB Output is correct
16 Correct 56 ms 2948 KB Output is correct
17 Correct 48 ms 2840 KB Output is correct
18 Correct 40 ms 2712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 384 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 10 ms 768 KB Output is correct
9 Correct 19 ms 1280 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 13 ms 1024 KB Output is correct
12 Correct 19 ms 1280 KB Output is correct
13 Correct 16 ms 1280 KB Output is correct
14 Correct 15 ms 1280 KB Output is correct
15 Correct 58 ms 2976 KB Output is correct
16 Correct 56 ms 2948 KB Output is correct
17 Correct 48 ms 2840 KB Output is correct
18 Correct 40 ms 2712 KB Output is correct
19 Correct 55 ms 3040 KB Output is correct
20 Correct 61 ms 2996 KB Output is correct
21 Correct 44 ms 2968 KB Output is correct
22 Correct 42 ms 2756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 384 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 10 ms 768 KB Output is correct
9 Correct 19 ms 1280 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 13 ms 1024 KB Output is correct
12 Correct 19 ms 1280 KB Output is correct
13 Correct 16 ms 1280 KB Output is correct
14 Correct 15 ms 1280 KB Output is correct
15 Correct 58 ms 2976 KB Output is correct
16 Correct 56 ms 2948 KB Output is correct
17 Correct 48 ms 2840 KB Output is correct
18 Correct 40 ms 2712 KB Output is correct
19 Correct 55 ms 3040 KB Output is correct
20 Correct 61 ms 2996 KB Output is correct
21 Correct 44 ms 2968 KB Output is correct
22 Correct 42 ms 2756 KB Output is correct
23 Correct 55 ms 3072 KB Output is correct
24 Correct 54 ms 3072 KB Output is correct
25 Correct 49 ms 2956 KB Output is correct
26 Correct 44 ms 2828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 384 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 10 ms 768 KB Output is correct
9 Correct 19 ms 1280 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 13 ms 1024 KB Output is correct
12 Correct 19 ms 1280 KB Output is correct
13 Correct 16 ms 1280 KB Output is correct
14 Correct 15 ms 1280 KB Output is correct
15 Correct 58 ms 2976 KB Output is correct
16 Correct 56 ms 2948 KB Output is correct
17 Correct 48 ms 2840 KB Output is correct
18 Correct 40 ms 2712 KB Output is correct
19 Correct 55 ms 3040 KB Output is correct
20 Correct 61 ms 2996 KB Output is correct
21 Correct 44 ms 2968 KB Output is correct
22 Correct 42 ms 2756 KB Output is correct
23 Correct 55 ms 3072 KB Output is correct
24 Correct 54 ms 3072 KB Output is correct
25 Correct 49 ms 2956 KB Output is correct
26 Correct 44 ms 2828 KB Output is correct
27 Correct 63 ms 3124 KB Output is correct
28 Correct 59 ms 3128 KB Output is correct
29 Incorrect 46 ms 3060 KB Wrong Answer [2]
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 384 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 10 ms 768 KB Output is correct
9 Correct 19 ms 1280 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 13 ms 1024 KB Output is correct
12 Correct 19 ms 1280 KB Output is correct
13 Correct 16 ms 1280 KB Output is correct
14 Correct 15 ms 1280 KB Output is correct
15 Correct 58 ms 2976 KB Output is correct
16 Correct 56 ms 2948 KB Output is correct
17 Correct 48 ms 2840 KB Output is correct
18 Correct 40 ms 2712 KB Output is correct
19 Correct 55 ms 3040 KB Output is correct
20 Correct 61 ms 2996 KB Output is correct
21 Correct 44 ms 2968 KB Output is correct
22 Correct 42 ms 2756 KB Output is correct
23 Correct 55 ms 3072 KB Output is correct
24 Correct 54 ms 3072 KB Output is correct
25 Correct 49 ms 2956 KB Output is correct
26 Correct 44 ms 2828 KB Output is correct
27 Correct 63 ms 3124 KB Output is correct
28 Correct 59 ms 3128 KB Output is correct
29 Incorrect 46 ms 3060 KB Wrong Answer [2]
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 384 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 10 ms 768 KB Output is correct
9 Correct 19 ms 1280 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 13 ms 1024 KB Output is correct
12 Correct 19 ms 1280 KB Output is correct
13 Correct 16 ms 1280 KB Output is correct
14 Correct 15 ms 1280 KB Output is correct
15 Correct 58 ms 2976 KB Output is correct
16 Correct 56 ms 2948 KB Output is correct
17 Correct 48 ms 2840 KB Output is correct
18 Correct 40 ms 2712 KB Output is correct
19 Correct 55 ms 3040 KB Output is correct
20 Correct 61 ms 2996 KB Output is correct
21 Correct 44 ms 2968 KB Output is correct
22 Correct 42 ms 2756 KB Output is correct
23 Correct 55 ms 3072 KB Output is correct
24 Correct 54 ms 3072 KB Output is correct
25 Correct 49 ms 2956 KB Output is correct
26 Correct 44 ms 2828 KB Output is correct
27 Correct 63 ms 3124 KB Output is correct
28 Correct 59 ms 3128 KB Output is correct
29 Incorrect 46 ms 3060 KB Wrong Answer [2]
30 Halted 0 ms 0 KB -