답안 #171011

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
171011 2019-12-27T04:05:38 Z dndhk popa (BOI18_popa) C++14
100 / 100
108 ms 456 KB
#include <bits/stdc++.h>
#include "popa.h"
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

const int MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N = 1000;
/*
int query(int x, int y, int z, int w){
	printf("%d %d %d %d", x, y, z, w);
	int ret;
	scanf("%d", &ret);
	return ret;
}*/

vector<int> v;

int solve(int N, int* Left, int* Right){
	int r = 0;
	Left[0] = Right[0] = -1;
	v.pb(0);
	for(int i=1; i<N; i++){
		Left[i] = Right[i] = -1;
		while(!v.empty() && query(v.back(), i, i, i)==1){
			Left[i] = v.back();
			v.pop_back();
		}
		if(v.empty()){
			r = i;
		}else{
			Right[v.back()] = i;
		}
		v.pb(i);
	}
	while(!v.empty())	v.pop_back();
	return r;
}
/*
int le[MAX_N+1], ri[MAX_N+1];

int main(){
	int n;
	scanf("%d", &n);
	cout<<solve(n, le, ri)<<endl;
	for(int i=0; i<n; i++){
		cout<<le[i]<<" "<<ri[i]<<endl;
	}
}*/
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 248 KB Output is correct
2 Correct 12 ms 376 KB Output is correct
3 Correct 7 ms 248 KB Output is correct
4 Correct 11 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 380 KB Output is correct
2 Correct 79 ms 332 KB Output is correct
3 Correct 40 ms 452 KB Output is correct
4 Correct 49 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 94 ms 376 KB Output is correct
2 Correct 108 ms 324 KB Output is correct
3 Correct 88 ms 456 KB Output is correct
4 Correct 108 ms 324 KB Output is correct