#include <bits/stdc++.h> using namespace std; //Jakub Bronowski, III LO Gdynia, PA 2020 Runda 1 //Zadanie Mieszanie Kolorow [B] int instr[1000010][4] = {0}; int ans1 = 0, ans2 = 0, ans3 = 0; int n,m, result = 0; int main() { scanf("%d %d", &n, &m); for(int i=0; i<m; ++i) { int a,b,c; scanf("%d%d%d", &a, &b, &c); ++instr[a][c]; --instr[b+1][c]; } for(int i=1; i<=n; ++i) { ans1 += instr[i][1]; ans2 += instr[i][2]; ans3 += instr[i][3]; if(ans1 > 0 && ans2 > 0 && ans3 < 1 ) ++result; } printf("%d", result); 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 | #include <bits/stdc++.h> using namespace std; //Jakub Bronowski, III LO Gdynia, PA 2020 Runda 1 //Zadanie Mieszanie Kolorow [B] int instr[1000010][4] = {0}; int ans1 = 0, ans2 = 0, ans3 = 0; int n,m, result = 0; int main() { scanf("%d %d", &n, &m); for(int i=0; i<m; ++i) { int a,b,c; scanf("%d%d%d", &a, &b, &c); ++instr[a][c]; --instr[b+1][c]; } for(int i=1; i<=n; ++i) { ans1 += instr[i][1]; ans2 += instr[i][2]; ans3 += instr[i][3]; if(ans1 > 0 && ans2 > 0 && ans3 < 1 ) ++result; } printf("%d", result); return 0; } |