#include <iostream>
using namespace std;
#define ull unsigned long long
ull n, m, l, r;
int ileZ = 0;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
char a = 'B';
int k;
//int puszki[n];
char kolory[n];
for (ull i = 0; i < n; ++i) {
//puszki[i] = 0;
kolory[i] = 'B';
}
for (ull i = 0; i < m; ++i) {
cin >> l >> r >> k;
if (k == 1)
a = 'z';
else if (k == 2)
a = 'N';
else if (k == 3)
a = 'C';
for (int j = l; j <= r; ++j) {
if (kolory[j] == 'B')
kolory[j] = a;
else if (kolory[j] == 'z') {
if (a == 'N') {
kolory[j] = 'Z';
++ileZ;
} else if (a == 'C')
kolory[j] = 'P';
} else if (kolory[j] == 'N') {
if (a == 'z') {
kolory[j] = 'Z';
++ileZ;
} else if (a == 'C')
kolory[j] = 'F';
} else if (kolory[j] == 'Z') {
if (a != 'z' && a != 'N') {
kolory[j] = 'G';
--ileZ;
}
}
}
}
cout << ileZ;
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | #include <iostream> using namespace std; #define ull unsigned long long ull n, m, l, r; int ileZ = 0; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; char a = 'B'; int k; //int puszki[n]; char kolory[n]; for (ull i = 0; i < n; ++i) { //puszki[i] = 0; kolory[i] = 'B'; } for (ull i = 0; i < m; ++i) { cin >> l >> r >> k; if (k == 1) a = 'z'; else if (k == 2) a = 'N'; else if (k == 3) a = 'C'; for (int j = l; j <= r; ++j) { if (kolory[j] == 'B') kolory[j] = a; else if (kolory[j] == 'z') { if (a == 'N') { kolory[j] = 'Z'; ++ileZ; } else if (a == 'C') kolory[j] = 'P'; } else if (kolory[j] == 'N') { if (a == 'z') { kolory[j] = 'Z'; ++ileZ; } else if (a == 'C') kolory[j] = 'F'; } else if (kolory[j] == 'Z') { if (a != 'z' && a != 'N') { kolory[j] = 'G'; --ileZ; } } } } cout << ileZ; return 0; } |
English