扣:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
int q[300][300][300]={0};
int t3[301][301][301]={0};//建表用
int a,b,c;
void chart2(int,int,int);//建t3 n小的時候比較快
int s(int,int,int,int);
int n0();
/*
void printq();//印出q
void printt3();//印出t3
void chart1();//建t3的另一種方法 n大的時候比較快
*/
signed main(){
ios::sync_with_stdio(0),cin.tie(0);
cin>>a>>b>>c;
int n;cin>>n;
if(n==0){
cout<<n0()<<endl;return 0;
}
int x,y,z;
int lc=a*b*c-n;
while(n--)cin>>x>>y>>z,q[x-1][y-1][z-1]=1,chart2(x,y,z);
for(int i=0;i<a;i++)for(int j=0;j<b;j++)for(int k=0;k<c;k++)for(int l=2;(l+i<=a)*(l+j<=b)*(l+k<=c);l++){
if(s(i,j,k,l)==0)lc++;
else break;
}
cout<<lc<<endl;
}
int s(int i,int j,int k,int l){
return t3[i+l][j+l][k+l]-(t3[i][j+l][k+l]+t3[i+l][j][k+l]+t3[i+l][j+l][k])+(t3[i][j][k+l]+t3[i][j+l][k]+t3[i+l][j][k])-t3[i][j][k];
}
void chart2(int x,int y,int z){
for(int i=x;i<=a;i++)for(int j=y;j<=b;j++)for(int k=z;k<=c;k++)t3[i][j][k]++;
}
int n0(){
int t=0,m=min(a,min(b,c));
for(int i=0;i<m;i++)t+=(a-i)*(b-i)*(c-i);
return t;
}
/*
void chart1(){
for(int i=0;i<a;i++){
int t2[301][301]={0};
for(int j=0;j<b;j++){
int t1[301]={0};
for(int k=0;k<c;k++){
t1[k+1]=t1[k]+q[i][j][k];
t2[j+1][k+1]=t2[j][k+1]+t1[k+1];
t3[i+1][j+1][k+1]=t3[i][j+1][k+1]+t2[j+1][k+1];
}
}
}
}
void printt3(){
for(int i=0;i<=a;i++){
for(int j=0;j<=b;j++){
for(int k=0;k<=c;k++)cout<<t3[i][j][k]<<" ";cout<<endl;
}
cout<<endl;
}
}
void printq(){
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
for(int k=0;k<c;k++)cout<<q[i][j][k];cout<<endl;
}
cout<<endl;
}
}
*/