This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long
#define append push_back
#define all(x) (x).begin(),(x).end()
void solvefor1(){
ll r;
int n,m,o,p;
cin>>n>>o>>m;
vector<int> v;
for(int i=0;i<n;i++){
cin>>p;
v.append(p);
}
sort(all(v));
for(int i=r=0;i<n;i++){
p=i;
for(int j=65536;j>0;j/=2){
if(p+j>=n) continue;
if(v[p+j]-v[i]<=o) p+=j;
}
r+=p-i;
}
cout<<r;
}
void solvefor2(){
int n,m,o,p,q,r;
cin>>n>>o>>m;
vector<int> x,y;
for(int i=0;i<n;i++){
cin>>p>>q;
x.append(p);
y.append(q);
}
for(int i=r=0;i<n;i++)
for(int j=i+1;j<n;j++)
r+=(abs(x[i]-x[j])+abs(y[i]-y[j])<=o);
cout<<r;
}
void solvefor3(){
int n,m,o,p,q,r;
cin>>n>>o>>m;
vector<int> x,y,z;
for(int i=0;i<n;i++){
cin>>p>>q>>r;
x.append(p);
y.append(q);
z.append(r);
}
for(int i=r=0;i<n;i++)
for(int j=i+1;j<n;j++)
r+=(abs(x[i]-x[j])+abs(y[i]-y[j])
+abs(z[i]-z[j])<=o);
cout<<r;
}
void solve(){
int t;
cin>>t;
if(t==1) solvefor1();
if(t==2) solvefor2();
if(t==3) solvefor3();
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
solve();
return 0;
}
# | 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... |