#include using namespace std; using ll=long long; #define rep(i,n) for(int i=0;i=0;i--) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} struct union_find { public: explicit union_find() {} explicit union_find(int N) : n(N), par(N, -1), siz(N, 1) {} int find(int x) { assert(0 <= x && x < n); if (par[x] == -1) return x; par[x] = find(par[x]); return par[x]; } int same(int x, int y) { assert(0 <= x && x < n); assert(0 <= y && y < n); return find(x) == find(y); } int size(int x) { assert(0 <= x && x < n); return siz[find(x)]; } bool unite(int x, int y) { assert(0 <= x && x < n); assert(0 <= y && y < n); x = find(x); y = find(y); if (x == y) return false; if (siz[x] < siz[y]) std::swap(x, y); siz[x] += siz[y]; par[y] = x; return true; } private: int n; std::vector par, siz; }; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N,A,B; cin>>N>>A>>B; vectorX(N); for(int i=0;i>X[i]; vectorP(N),Q(N); int r=0; for(int l=0;lI(N); for(int i=0;i0)uf.unite(i,i+1); if(P[i]