#include <bits/stdc++.h>
#define ll long long
using namespace std;
int w, t;
static vector<short> sums = {1,8,9,27,28,35,36};
bool checkSum(int sum){
for(auto& i : sums){
if(sum == i) return true;
}
return false;
}
int main(){
scanf("%d %d", &w, &t);
vector<short>paint(w, 0);
for(int i = 0; i<t;i++){
int f,l,c;
scanf("%d %d %d", &f,&l,&c);
for(int j = f-1; j<l;j++){
if(checkSum(paint[j]+(c*c*c))) paint[j] += c*c*c;
}
}
int g = 0;
for(auto&i : paint){
if(i == 9) g++;
}
printf("%d\n", g);
}
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 | #include <bits/stdc++.h> #define ll long long using namespace std; int w, t; static vector<short> sums = {1,8,9,27,28,35,36}; bool checkSum(int sum){ for(auto& i : sums){ if(sum == i) return true; } return false; } int main(){ scanf("%d %d", &w, &t); vector<short>paint(w, 0); for(int i = 0; i<t;i++){ int f,l,c; scanf("%d %d %d", &f,&l,&c); for(int j = f-1; j<l;j++){ if(checkSum(paint[j]+(c*c*c))) paint[j] += c*c*c; } } int g = 0; for(auto&i : paint){ if(i == 9) g++; } printf("%d\n", g); } |
English