# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
697340 |
2023-02-09T10:15:29 Z |
starplat |
Pairs (IOI07_pairs) |
C++14 |
|
2964 ms |
7068 KB |
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
using namespace std;
int b,n,d,m,ans;
void d1(){
vector<int> c;
for (int i=0;i<n;i++){
c.push_back(0); cin>>c[i];
}
sort(c.begin(),c.end());
int pt=0;
for (int i=0;i<n;i++){
while (pt+1<n && c[pt+1]<=c[i]+d) ++pt;
ans+=pt-i;
}
}
void d2(){
vector<pair<int,int>> c;
}
int frq[85][85][85],x[100005],y[100005],z[100005];
void d3(){
for (int i=1;i<=n;i++){
cin>>x[i]>>y[i]>>z[i];
frq[x[i]][y[i]][z[i]]++;
}
for (int i=1;i<=m;i++){
for (int j=1;j<=m;j++){
for (int k=1;k<=m;k++) frq[i][j][k]+=frq[i][j][k-1];
}
}
for (int k=1;k<=n;k++){
for (int i=1;i<=m;i++){
for (int j=1;j<=m;j++){
int dist=d-abs(x[k]-i)-abs(y[k]-j);
if (dist<0) continue;
ans+=frq[i][j][min(m,z[k]+dist)]-frq[i][j][max(0LL,z[k]-dist-1)];
}
}
}
ans-=n; ans/=2;
}
signed main(){
cin>>b>>n>>d>>m;
if (b==1) d1();
else if (b==2) d2();
else d3();
cout<<ans<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
1400 KB |
Output is correct |
2 |
Correct |
26 ms |
1440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
1408 KB |
Output is correct |
2 |
Correct |
43 ms |
1344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
1516 KB |
Output is correct |
2 |
Correct |
41 ms |
1356 KB |
Output is correct |
3 |
Correct |
46 ms |
1428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
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 |
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 |
Correct |
15 ms |
4392 KB |
Output is correct |
2 |
Correct |
26 ms |
4308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
2732 KB |
Output is correct |
2 |
Correct |
79 ms |
3120 KB |
Output is correct |
3 |
Correct |
86 ms |
3068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
612 ms |
5252 KB |
Output is correct |
2 |
Correct |
1530 ms |
5640 KB |
Output is correct |
3 |
Correct |
1310 ms |
5644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1307 ms |
6680 KB |
Output is correct |
2 |
Correct |
2820 ms |
7064 KB |
Output is correct |
3 |
Correct |
2964 ms |
7068 KB |
Output is correct |