답안 #61946

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
61946 2018-07-27T06:02:44 Z 윤교준(#1798) popa (BOI18_popa) C++11
100 / 100
153 ms 756 KB
#include "popa.h"
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define befv(V) ((V)[sz(V)-2])
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 1005;

static vector<int> G[MAXN];

static int N;

int solve(int N, int *_L, int *_R) {
	for(int i = 0; i < MAXN; i++) G[i].clear();
	::N = N;

	vector<int> V(1, 0);
	for(int i = 1; i < N; i++) {
		int j = sz(V)-1;
		for(; 0 <= j && query(V[j], i, i, i); j--);
		for(; j+2 < sz(V);) {
			G[befv(V)].eb(V.back());
			V.pop_back();
		}
		if(sz(V)-1 == j) V.eb(i);
		else {
			G[i].eb(V.back());
			V.back() = i;
		}
	}
	for(int i = 1; i < sz(V); i++) G[V[i-1]].eb(V[i]);

	for(int i = 0; i < N; i++) {
		_L[i] = _R[i] = -1;
		for(int v : G[i]) {
			if(v < i) _L[i] = v;
			else _R[i] = v;
		}
	}
	return V[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 328 KB Output is correct
2 Correct 8 ms 328 KB Output is correct
3 Correct 14 ms 472 KB Output is correct
4 Correct 12 ms 556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 131 ms 672 KB Output is correct
2 Correct 88 ms 672 KB Output is correct
3 Correct 57 ms 672 KB Output is correct
4 Correct 153 ms 692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 130 ms 740 KB Output is correct
2 Correct 127 ms 756 KB Output is correct
3 Correct 90 ms 756 KB Output is correct
4 Correct 74 ms 756 KB Output is correct