#include <bits/stdc++.h> using namespace std; #define Vint vector<int> #define LL long long LL n,m,l,r,k; int main() { ios_base::sync_with_stdio(0); cin >> n >> m; Vint a(n,-1); for(int i=0;i<m;i++){ cin >> l >> r >> k; for(int j=l-1;j<r;j++){ if(k==1) if(a[j]==1 || a[j] == 4 || a[j] == 5 || a[j] == 7) continue; else a[j] += (k+1); else if(k==2) if(a[j]==2 || a[j] == 4 || a[j] == 6 || a[j] == 7) continue; else a[j] += (k+1); else if(a[j]==3 || a[j] == 5 || a[j] == 6 || a[j] == 7) continue; else a[j] += (k+1); } } LL c=0; for(int i=0;i<n;i++) if(a[i]==4) c++; cout << c; 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 | #include <bits/stdc++.h> using namespace std; #define Vint vector<int> #define LL long long LL n,m,l,r,k; int main() { ios_base::sync_with_stdio(0); cin >> n >> m; Vint a(n,-1); for(int i=0;i<m;i++){ cin >> l >> r >> k; for(int j=l-1;j<r;j++){ if(k==1) if(a[j]==1 || a[j] == 4 || a[j] == 5 || a[j] == 7) continue; else a[j] += (k+1); else if(k==2) if(a[j]==2 || a[j] == 4 || a[j] == 6 || a[j] == 7) continue; else a[j] += (k+1); else if(a[j]==3 || a[j] == 5 || a[j] == 6 || a[j] == 7) continue; else a[j] += (k+1); } } LL c=0; for(int i=0;i<n;i++) if(a[i]==4) c++; cout << c; return 0; } |