0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-28 16:11:58 +00:00

P1276 校门外的树(增强版)

R52354554
This commit is contained in:
Baoshuo Ren 2021-07-03 21:13:43 +08:00 committed by Baoshuo Ren
parent a65d24c602
commit 86c10430f3
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

View File

@ -0,0 +1,36 @@
#include <bits/stdc++.h>
using namespace std;
int l, n, op, x, y, ans1, ans2, a[10005], b[10005];
int main() {
cin >> l >> n;
for (int i = 0; i <= l; i++) {
a[i] = 1;
}
for (int i = 0; i < n; i++) {
cin >> op >> x >> y;
if (op == 0) {
for (int j = x; j <= y; j++) {
if (a[j]) a[j] = 0;
}
} else if (op == 1) {
for (int j = x; j <= y; j++) {
if (!a[j]) {
a[j] = 1;
b[j]++;
}
}
}
}
for (int i = 0; i <= l; i++) {
if (b[i] && a[i]) ans1++;
if (b[i] - a[i] > 0) {
ans2 += b[i] - a[i];
}
}
cout << ans1 << endl
<< ans2 << endl;
return 0;
}