#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
int n, m;
cin >> n >> m;
vector<string> v(n, "");
for(int i=0;i<m;i++)
{
int l, r, k;
cin >> l >> r >> k;
for(int j=l;j<=r;j++)
{
v[j-1] += to_string(k);
}
}
int count = 0;
for(auto s:v)
{
if (s.find('1')!=string::npos && s.find('2')!=string::npos&&s.find('3')==string::npos)
count++;
}
cout << count;
}
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 | #include<iostream> #include<vector> #include<string> using namespace std; int main() { int n, m; cin >> n >> m; vector<string> v(n, ""); for(int i=0;i<m;i++) { int l, r, k; cin >> l >> r >> k; for(int j=l;j<=r;j++) { v[j-1] += to_string(k); } } int count = 0; for(auto s:v) { if (s.find('1')!=string::npos && s.find('2')!=string::npos&&s.find('3')==string::npos) count++; } cout << count; } |
English