Submission #697321

# Submission time Handle Problem Language Result Execution time Memory
697321 2023-02-09T08:45:46 Z abcdehello Pairs (IOI07_pairs) C++17
0 / 100
69 ms 9404 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans,b,n,d,m;
void _1d(){
	if (d>m) d=m;
	vector<ll> a(n);
	for (int i=0;i<n;i++) cin >> a[i];
	a.push_back(-1);a.push_back(INT_MAX);
	sort(a.begin(),a.end());
	for (int i=1;i<=n;i++){
		ans += (lower_bound(a.begin(),a.end(),a[i]+d+1)-lower_bound(a.begin(),a.end(),a[i]-d)-1);
	}
	cout << ans/2 << "\n";
}
void _2d(){
}
void _3d(){
	if (d>3*m) d=3*m;
	vector<ll> a[80][80];
	vector<pair<pair<ll,ll>,ll> > c(0);
	for (int i=0;i<=75;i++){
		for (int j=0;j<=75;j++){
			a[i][j].resize(0);
			a[i][j].push_back(-1);
			a[i][j].push_back(INT_MAX);
		}
	}
	for (int i=0;i<n;i++){
		ll x,y,z;
		cin >> x >> y >> z;
		a[x][y].push_back(z);
		c.push_back({{x,y},z});
	}
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++) sort(a[i][j].begin(),a[i][j].end());
	}
	for (int i=0;i<n;i++){
		ll x=c[i].first.first,y=c[i].first.second,z=c[i].second;
		for (int xx=0;xx<=m;xx++){
			for (int yy=0;yy<=m;yy++){
				ll rem=d-abs(x-xx)-abs(y-yy);
				if (rem<0) continue;
				ll cnt=(lower_bound(a[xx][yy].begin(),a[xx][yy].end(),z+rem+1)-lower_bound(a[xx][yy].begin(),a[xx][yy].end(),z-rem));
				ans += max(cnt-1,0LL);
			}
		}
	}
	cout << ans/2 << "\n";
}
int main(){
	cin >> b >> n >> d >> m;
	if (b==1) _1d();
	else if (b==2) _2d();
	else _3d();
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 2232 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 2708 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 2612 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 316 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1108 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 51 ms 8688 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 55 ms 9384 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 69 ms 9404 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -