답안 #250477

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
250477 2020-07-18T07:10:49 Z lyc Minerals (JOI19_minerals) C++14
40 / 100
19 ms 2548 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[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 ((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), Del(i);
	}
	
	rec(a,b);
}
# 결과 실행 시간 메모리 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 1 ms 384 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 11 ms 896 KB Output is correct
5 Correct 18 ms 1280 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 1 ms 384 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 18 ms 1280 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 18 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 18 ms 1280 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 1 ms 384 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 18 ms 1280 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 18 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 18 ms 1280 KB Output is correct
15 Incorrect 17 ms 2548 KB Wrong Answer [4]
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 1 ms 384 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 18 ms 1280 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 18 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 18 ms 1280 KB Output is correct
15 Incorrect 17 ms 2548 KB Wrong Answer [4]
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 1 ms 384 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 18 ms 1280 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 18 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 18 ms 1280 KB Output is correct
15 Incorrect 17 ms 2548 KB Wrong Answer [4]
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 1 ms 384 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 18 ms 1280 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 18 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 18 ms 1280 KB Output is correct
15 Incorrect 17 ms 2548 KB Wrong Answer [4]
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 1 ms 384 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 18 ms 1280 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 18 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 18 ms 1280 KB Output is correct
15 Incorrect 17 ms 2548 KB Wrong Answer [4]
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 1 ms 384 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 18 ms 1280 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 18 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 18 ms 1280 KB Output is correct
15 Incorrect 17 ms 2548 KB Wrong Answer [4]
16 Halted 0 ms 0 KB -