답안 #197685

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
197685 2020-01-22T10:01:41 Z dennisstar Long Mansion (JOI17_long_mansion) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define eb emplace_back
#define all(V) (V).begin(), (V).end()
using namespace std;
typedef long long ll;
typedef vector<int> vim;

int N, Q;
vim C, B, A[500010], pos[500010];
vim l, r;
int Xk, Yk, lb;

inline bool Find(int L, int R, int X)
	lb=lower_bound(all(pos[X]), L)-pos[X].begin();
	return (lb<pos[X].size()&&pos[X][lb]<=R);
}

int main() {
	scanf("%d", &N);
	C.resize(N); B.resize(N+1); l.resize(N+1); r.resize(N+1);
	for (int i=1; i<N; i++) scanf("%d", &C[i]);
	for (int i=1; i<=N; i++) {
		scanf("%d", &B[i]);
		A[i].resize(B[i]);
		for (auto &j:A[i]) scanf("%d", &j);
		for (auto &j:A[i]) pos[j].eb(i);
	}
	for (int i=1; i<=N; i++) {
		l[i]=r[i]=i;
		for (int fl; ; ) {
			fl=0;
			if (l[i]>1 && Find(l[i], r[i], C[l[i]-1])) {
				r[i]=max(r[i], r[l[i]-1]);
				l[i]=l[l[i]-1];
				fl=1;
			}
			else if (r[i]<N && Find(l[i], r[i], C[r[i]])) { r[i]++; fl=1; }
			if (!fl) break;
		}
	}
	scanf("%d", &Q);
	while (Q--) {
		scanf("%d %d", &Xk, &Yk);
		if (l[Xk]<=Yk&&Yk<=r[Xk]) puts("YES");
		else puts("NO");
	}
	return 0;
}

Compilation message

long_mansion.cpp:14:2: error: expected initializer before 'lb'
  lb=lower_bound(all(pos[X]), L)-pos[X].begin();
  ^~
long_mansion.cpp:15:2: error: expected unqualified-id before 'return'
  return (lb<pos[X].size()&&pos[X][lb]<=R);
  ^~~~~~
long_mansion.cpp:16:1: error: expected declaration before '}' token
 }
 ^