Skip to content

ABC-256

C Union of Interval

URLURL\:\to https://atcoder.jp/contests/abc256/tasks/abc256_d

#imos

int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll LIMIT = 2e5;
ll n; cin >> n;
vec<ll> a(LIMIT+1, 0);
rep(i, 0, n) {
ll l, r; cin >> l >> r;
a[l]++; a[r]--;
}
rep(i, 0, LIMIT) a[i+1] += a[i];
ll left = 0;
bool flg = false;
rep(i, 0, LIMIT+1) {
if (a[i] > 0 && !flg) {
left = i;
flg = true;
} else if (a[i] == 0 && flg) {
flg = false;
out(left, i);
}
}
return 0;
}

解法

imos法でやるだけ


D

URLURL\:\to

解法


E

URLURL\:\to

解法