This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
using namespace std;
int b,n,d,m,ans;
void d1(){
vector<int> c;
for (int i=0;i<n;i++){
c.push_back(0); cin>>c[i];
}
sort(c.begin(),c.end());
int pt=0;
for (int i=0;i<n;i++){
while (pt+1<n && c[pt+1]<=c[i]+d) ++pt;
ans+=pt-i;
}
}
void d2(){
vector<pair<int,int>> c;
}
int frq[85][85][85],x[100005],y[100005],z[100005];
void d3(){
for (int i=1;i<=n;i++){
cin>>x[i]>>y[i]>>z[i];
frq[x[i]][y[i]][z[i]]++;
}
for (int i=1;i<=m;i++){
for (int j=1;j<=m;j++){
for (int k=1;k<=m;k++) frq[i][j][k]+=frq[i][j][k-1];
}
}
for (int k=1;k<=n;k++){
for (int i=1;i<=m;i++){
for (int j=1;j<=m;j++){
int dist=d-abs(x[k]-i)-abs(y[k]-j);
if (dist<0) continue;
ans+=frq[i][j][z[k]+dist]-frq[i][j][z[k]-1];
}
}
}
ans-=n;
}
signed main(){
cin>>b>>n>>d>>m;
if (b==1) d1();
else if (b==2) d2();
else d3();
cout<<ans<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |