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:
parent
a65d24c602
commit
86c10430f3
36
Luogu/problem/P1276/P1276.cpp
Normal file
36
Luogu/problem/P1276/P1276.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user