# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
725265 | Baytoro | Pairs (IOI07_pairs) | C++17 | 4070 ms | 3412 KiB |
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>
using namespace std;
#define ios ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
#define endl '\n'
#define ll long long
#define int long long
void fopn(string name){
freopen((name+".in").c_str(),"r",stdin);
freopen((name+".out").c_str(),"w",stdout);
}
const ll INF=1e18,mod=1e9+9,N=1e5+5;
struct triple{
int x,y,z;
};
void solve(){
int b,n,d,m;
cin>>b>>n>>d>>m;
if(b==1){
vector<int> a(n);
for(int i=0;i<n;i++) cin>>a[i];
sort(all(a));
int ans=0;
for(int i=0;i<n;i++){
int j=upper_bound(all(a),a[i]+d)-a.begin();
ans+=j-i-1;
}
cout<<ans<<endl;
}
else if(b==2){
vector<pair<int,int>> a(n);
for(int i=0;i<n;i++){
cin>>a[i].fr>>a[i].sc;
}
int ans=0;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(abs(a[i].fr-a[j].fr)+abs(a[i].sc-a[j].sc)<=d) ans++;
}
}
cout<<ans<<endl;
}
else{
vector<triple> a(n);
for(int i=0;i<n;i++){
cin>>a[i].x>>a[i].y>>a[i].z;
}
int ans=0;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(abs(a[i].x-a[j].x)+abs(a[i].y-a[j].y)+abs(a[i].z-a[j].z)<=d) ans++;
}
}
cout<<ans<<endl;
}
}
main(){
//fopn("team");
ios;
int T=1;
//cin>>T;
for(int i=1;i<=T;i++){
//cout<<"Case #"<<i<<": ";
solve();
}
}
Compilation message (stderr)
# | 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... |