#include <bits/stdc++.h>
#define le length()
#define pb push_back
#define sz size()
using namespace std;
set<int> arr[1000005];
void dodanie(int pocz, int kon, int kol){
++kon;
while(pocz<kon){
arr[pocz].insert(kol);
++pocz;
}
}
void wyn(int pusz){
int ile=0;
for(int i=0;i<pusz;++i){
if(arr[i].size()==2){
if( (arr[i].find(1) != arr[i].end()) && (arr[i].find(2)) != arr[i].end()){
++ile;
}
}
}
printf("%d", ile);
}
int main(){
int pusz, op, pocz, kon, kol; scanf("%d%d", &pusz, &op);
for(int i=0;i<op;++i){
scanf("%d%d%d", &pocz, &kon, &kol);
dodanie(pocz, kon, kol);
}
wyn(pusz);
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 | #include <bits/stdc++.h> #define le length() #define pb push_back #define sz size() using namespace std; set<int> arr[1000005]; void dodanie(int pocz, int kon, int kol){ ++kon; while(pocz<kon){ arr[pocz].insert(kol); ++pocz; } } void wyn(int pusz){ int ile=0; for(int i=0;i<pusz;++i){ if(arr[i].size()==2){ if( (arr[i].find(1) != arr[i].end()) && (arr[i].find(2)) != arr[i].end()){ ++ile; } } } printf("%d", ile); } int main(){ int pusz, op, pocz, kon, kol; scanf("%d%d", &pusz, &op); for(int i=0;i<op;++i){ scanf("%d%d%d", &pocz, &kon, &kol); dodanie(pocz, kon, kol); } wyn(pusz); return 0; } |
English