#include #include using namespace std; using namespace atcoder; struct Interval { int l, r, id; }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector> obs(n+1); for(int i=0; i> a >> b; obs[a].push_back(b); } dsu uf(2*n); vector prev,cur; int cnt=0; int components=0; for(int i=1; i<=n; i++){ sort(obs[i].begin(),obs[i].end()); // 番兵 obs[i].push_back(n+1); cur.clear(); // 空き区間の生成 int l=1; for(int b:obs[i]){ if(lr2){ q++; } else{ p++; q++; } } swap(prev,cur); } cout << (components==2 ? "Yes" : "No") << '\n'; }