# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
94618 |
2019-01-21T19:18:25 Z |
SuperJava |
Pairs (IOI07_pairs) |
C++17 |
|
4000 ms |
3820 KB |
//fold
#ifndef KHALIL
#include <bits/stdc++.h>
#else
#include "header.h"
#endif
#define endl '\n'
#define mp make_pair
#define tostr(x) static_cast<ostringstream&>((ostringstream()<<dec<<x)).str()
#define rep(i,begin,end) for(auto i = begin;i < end;i++)
#define repr(i,begin,end) for(auto i = begin-1;i >= end;i--)
#define pb push_back
#define sz(a) ((int)(a).size())
#define fi first
#define se second
#define abs(a) ((a) < (0) ? (-1)*(a) : (a))
#define SQ(a) ((a)*(a))
#define eqd(a,b) (abs(a-b)<1e-9)
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename t> t in(t q){cin >> q;return q;}
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v){os << "[";for (int i = 0; i < sz(v); ++i) { os << v[i]; if (i != sz(v) - 1) os << ",";}os << "]";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const map<T, S>& v){for (auto it : v)os << "(" << it.first << ":" << it.second << ")";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const pair<T, S>& v){os << "(" << v.first << "," << v.second << ")";return os;}
const long double PI = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
//endfold
#define N (200'005)
#define MOD (1000000000l + 7l)
#define OO (1050000000)
#define OOL (1100000000000000000)
int main(){
//fold
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cout << setprecision(10);
//endfold
ll b,n,d,m;
cin >> b >> n >> d >> m;
if(b == 1){
vector<ll> v;
rep(i,0,n){
ll w;
cin >> w;
v.push_back(w);
}
sort(v.begin(), v.end());
ll ans = 0;
rep(i,0,n){
ans += upper_bound(v.begin(), v.end(),v[i]+d)-lower_bound(v.begin(), v.end(),v[i]-d)-1;
}
cout << ans/2;
}else if(b == 2){
vector<pair<ll,ll>> v;
rep(i,0,n){
ll w,q;
cin >> q >> w;
v.push_back({q,w});
}
ll ans = 0;
rep(i,0,n){
rep(j,i+1,n){
if(abs(v[i].first-v[j].first)+abs(v[i].second-v[j].second) <= d) ans++;
}
}
cout << ans;
}else{
vector<tuple<ll,ll,ll>> v;
rep(i,0,n){
ll w,q,e;
cin >> q >> w >> e;
v.push_back({q,w,e});
}
ll ans = 0;
rep(i,0,n){
rep(j,i+1,n){
ll q1,w1,e1;
ll q2,w2,e2;
tie(q1,w1,e1) = v[i];
tie(q2,w2,e2) = v[j];
if(abs(q1-q2)+abs(w2-w1)+abs(e2-e1) <= d) ans++;
}
}
cout << ans;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
1440 KB |
Output is correct |
2 |
Correct |
19 ms |
1524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
1524 KB |
Output is correct |
2 |
Correct |
24 ms |
1524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
1524 KB |
Output is correct |
2 |
Correct |
27 ms |
1524 KB |
Output is correct |
3 |
Correct |
25 ms |
1520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4093 ms |
2664 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4051 ms |
2672 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4043 ms |
2668 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4041 ms |
3820 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4041 ms |
3820 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4051 ms |
3816 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |