# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
697325 |
2023-02-09T08:54:11 Z |
abcdehello |
Pairs (IOI07_pairs) |
C++17 |
|
293 ms |
9448 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(0);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;
cerr << (lower_bound(a.begin(),a.end(),a[i]+d+1)-lower_bound(a.begin(),a.end(),a[i]-d))-1 << endl;
}
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(0);
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 |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
274 ms |
2124 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
293 ms |
2636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
287 ms |
2604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
0 ms |
212 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 |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
1236 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
64 ms |
8696 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
65 ms |
9420 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
63 ms |
9448 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |