Submission #262601

# Submission time Handle Problem Language Result Execution time Memory
262601 2020-08-13T05:06:19 Z 임성재(#5086) Pairs (IOI07_pairs) C++17
30 / 100
38 ms 3748 KB
#include<bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(0);
#define pre(a) cout << fixed; cout.precision(a);
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define all(v) (v).begin() (v).end()
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;

struct point {
	ll x[3];
	point() {
		x[0] = x[1] = x[2] = 0;
	}

	bool operator<(point &p) {
		return mt(x[0], x[1], x[2]) < mt(p.x[0], p.x[1], p.x[2]);
	}
};

ll b, n, d, m;
point p[100010];

ll dist(int i, int j) {
	ll ret = 0;
	for(int k=0; k<3; k++) {
		ret += abs(p[i].x[k] - p[j].x[k]);
	}

	return ret;
}

int main() {
	fast;

	cin >> b >> n >> d >> m;

	for(int i=1; i<=n; i++) {
		for(int j=0; j<b; j++) {
			cin >> p[i].x[j];
		}
	}

	sort(p+1, p+n+1);

	ll ans = 0;
	int idx = 1;
	for(int i=1; i<=n; i++) {
		while(idx <= n && dist(idx, i) <= d) idx++;

		ans += idx - i - 1;
	}

	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 2840 KB Output is correct
2 Correct 18 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 2816 KB Output is correct
2 Correct 22 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 2816 KB Output is correct
2 Correct 24 ms 2908 KB Output is correct
3 Correct 28 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2688 KB Output is correct
2 Incorrect 2 ms 2688 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 3264 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 3576 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 3748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 3328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 3456 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 3456 KB Output isn't correct
2 Halted 0 ms 0 KB -