#include <iostream> #include <bitset> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); bitset<1000000> tab[3]; bitset<1000000> x; x.set(); tab[0].reset(); tab[1].reset(); tab[2].reset(); int a, b, c, d, e; cin >> a >> b; for(int i = 0; i < b; i ++) { cin >> c >> d >> e; tab[e-1]|= ((x << c)&( x >> (999999 - d))); } tab[0] = (tab[0]&tab[1])&(~tab[2]); cout<< tab[0].count(); 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 | #include <iostream> #include <bitset> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); bitset<1000000> tab[3]; bitset<1000000> x; x.set(); tab[0].reset(); tab[1].reset(); tab[2].reset(); int a, b, c, d, e; cin >> a >> b; for(int i = 0; i < b; i ++) { cin >> c >> d >> e; tab[e-1]|= ((x << c)&( x >> (999999 - d))); } tab[0] = (tab[0]&tab[1])&(~tab[2]); cout<< tab[0].count(); return 0; } |