/*
what does odbyt mean?
who is paris platynov and why is he rhyming about stara and stary?
░░░░░░░░░░░░░▄▄▀▀▀▀▀▀▄▄
░░░░░░░░░░▄▄▀▄▄▄█████▄▄▀▄
░░░░░░░░▄█▀▒▀▀▀█████████▄█▄
░░░░░░▄██▒▒▒▒▒▒▒▒▀▒▀▒▀▄▒▀▒▀▄
░░░░▄██▀▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▄
░░░░██▀▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▌
░░░▐██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▐█
░▄▄███▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█
▐▒▄▀██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▐▌
▌▒▒▌▒▀▒▒▒▒▒▒▄▀▀▄▄▒▒▒▒▒▒▒▒▒▒▒▒█▌
▐▒▀▒▌▒▒▒▒▒▒▒▄▄▄▄▒▒▒▒▒▒▒▀▀▀▀▄▒▐
░█▒▒▌▒▒▒▒▒▒▒▒▀▀▒▀▒▒▐▒▄▀██▀▒▒▒▌
░░█▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▐▒▒▒▒▒▒▒▒█
░░░▀▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▌▒▒▒▒▒▒▄▀
░░░▐▒▒▒▒▒▒▒▒▒▄▀▐▒▒▒▒▒▐▒▒▒▒▄▀
░░▄▌▒▒▒▒▒▒▒▄▀▒▒▒▀▄▄▒▒▒▌▒▒▒▐▀▀▀▄▄▄
▄▀░▀▄▒▒▒▒▒▒▒▒▀▀▄▄▄▒▄▄▀▌▒▒▒▌░░░░░░
▐▌░░░▀▄▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▄▀░░░░░░░
░█░░░░░▀▄▄▒▒▒▒▒▒▒▒▒▒▒▒▄▀░█░░░░░▒▒
░░█░░░░░░░▀▄▄▄▒▒▒▒▒▒▄▀░░░░█░░░▒▒▒
░░░█░░░░░░░░░▌▀▀▀▀▀▀▐░░░░░▐▌░▒▒▒▒
░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒
░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒░
░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒░░
░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒░░░
░░░░░░░░░░░░░░░░░░░░░░░▄▄▒▒▒▒▒░░░
░░░░░░░░░░░░░░░▄▄▄████████▒▒░░░░░
░░░░▄▄▄▄▄▄█████▀▀▀▀▀░░░░░░░░░░░░░
░░░▀▀▀▀▀▀▀░░░░░░░░░░░░░░░░░░░░░░░
NIE BIERZ TEGO BLUNTA SYNU
1 MARIHUANA = 1 ZNISZCZONE ŻYCIE
Papież chroni papież radzi
Papież nigdy cię nie zdradzi
słuchaj Papieża, żyj zdrowo i miej Boga w sercu
*/
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define satori int bepis;cin >> bepis;while(bepis--)
#define st first
#define nd second
#define mp make_pair
//#define int long long
using namespace std;
int32_t main()
{
std::ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n , m;
cin >> n >> m;
vector<int> u(4,0);
vector<int> a(n+1,0);
vector<int> b(n+1,0);
vector<int> c(n+1,0);
for(int i = 0;i<m;i++)
{
int l,r,d;
cin >> l >> r >> d;
if(r<n)
{
if(d == 1)a[r+1]-=1;
if(d == 2)b[r+1]-=1;
if(d == 3)c[r+1]-=1;
}
if(d == 1)a[l]+=1;
if(d == 2)b[l]+=1;
if(d == 3)c[l]+=1;
}
int ans = 0;
for(int i = 1;i<n+1;i++)
{
u[1]+=a[i];
u[2]+=b[i];
u[3]+=c[i];
if(u[1]>0 and u[2]>0 and u[3] == 0)ans++;
}
cout<< ans <<'\n';
}
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | /* what does odbyt mean? who is paris platynov and why is he rhyming about stara and stary? ░░░░░░░░░░░░░▄▄▀▀▀▀▀▀▄▄ ░░░░░░░░░░▄▄▀▄▄▄█████▄▄▀▄ ░░░░░░░░▄█▀▒▀▀▀█████████▄█▄ ░░░░░░▄██▒▒▒▒▒▒▒▒▀▒▀▒▀▄▒▀▒▀▄ ░░░░▄██▀▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▄ ░░░░██▀▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▌ ░░░▐██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▐█ ░▄▄███▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█ ▐▒▄▀██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▐▌ ▌▒▒▌▒▀▒▒▒▒▒▒▄▀▀▄▄▒▒▒▒▒▒▒▒▒▒▒▒█▌ ▐▒▀▒▌▒▒▒▒▒▒▒▄▄▄▄▒▒▒▒▒▒▒▀▀▀▀▄▒▐ ░█▒▒▌▒▒▒▒▒▒▒▒▀▀▒▀▒▒▐▒▄▀██▀▒▒▒▌ ░░█▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▐▒▒▒▒▒▒▒▒█ ░░░▀▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▌▒▒▒▒▒▒▄▀ ░░░▐▒▒▒▒▒▒▒▒▒▄▀▐▒▒▒▒▒▐▒▒▒▒▄▀ ░░▄▌▒▒▒▒▒▒▒▄▀▒▒▒▀▄▄▒▒▒▌▒▒▒▐▀▀▀▄▄▄ ▄▀░▀▄▒▒▒▒▒▒▒▒▀▀▄▄▄▒▄▄▀▌▒▒▒▌░░░░░░ ▐▌░░░▀▄▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▄▀░░░░░░░ ░█░░░░░▀▄▄▒▒▒▒▒▒▒▒▒▒▒▒▄▀░█░░░░░▒▒ ░░█░░░░░░░▀▄▄▄▒▒▒▒▒▒▄▀░░░░█░░░▒▒▒ ░░░█░░░░░░░░░▌▀▀▀▀▀▀▐░░░░░▐▌░▒▒▒▒ ░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒ ░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒░ ░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▒░░ ░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒▒░░░ ░░░░░░░░░░░░░░░░░░░░░░░▄▄▒▒▒▒▒░░░ ░░░░░░░░░░░░░░░▄▄▄████████▒▒░░░░░ ░░░░▄▄▄▄▄▄█████▀▀▀▀▀░░░░░░░░░░░░░ ░░░▀▀▀▀▀▀▀░░░░░░░░░░░░░░░░░░░░░░░ NIE BIERZ TEGO BLUNTA SYNU 1 MARIHUANA = 1 ZNISZCZONE ŻYCIE Papież chroni papież radzi Papież nigdy cię nie zdradzi słuchaj Papieża, żyj zdrowo i miej Boga w sercu */ #pragma GCC optimize("Ofast") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #define satori int bepis;cin >> bepis;while(bepis--) #define st first #define nd second #define mp make_pair //#define int long long using namespace std; int32_t main() { std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n , m; cin >> n >> m; vector<int> u(4,0); vector<int> a(n+1,0); vector<int> b(n+1,0); vector<int> c(n+1,0); for(int i = 0;i<m;i++) { int l,r,d; cin >> l >> r >> d; if(r<n) { if(d == 1)a[r+1]-=1; if(d == 2)b[r+1]-=1; if(d == 3)c[r+1]-=1; } if(d == 1)a[l]+=1; if(d == 2)b[l]+=1; if(d == 3)c[l]+=1; } int ans = 0; for(int i = 1;i<n+1;i++) { u[1]+=a[i]; u[2]+=b[i]; u[3]+=c[i]; if(u[1]>0 and u[2]>0 and u[3] == 0)ans++; } cout<< ans <<'\n'; } |
English