#include<bits/stdc++.h>
using namespace std;
int vis[100001],x,y,t,help,d[1000001];
map<pair<int,int>,int> mp;
vector<int> adj[100000];
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int DistanceSum(int N, int *X, int *Y) {
int sum = 0;
for (int i = 0; i < N; i++)
mp[{X[i],Y[i]}] = i;
for (int i = 0; i < N;i ++) {
for (int j = 0; j < 4; j++) {
x = X[i] + dx[j];
y = Y[i] + dy[j];
t = mp[{x,y}];
if (t) adj[i].push_back(t);
}
}
for (int i = 0; i < N; i++) {
help++;
queue<int> q;
q.push(i);
d[i] = 0;
vis[i] = help;
while (!q.empty()) {
x = q.front();
sum += d[x];
for (int i:adj[x]) {
if (vis[i] != help ) {
vis[i] = help;
d[i] = d[x] + 1;
q.push(x);
}
}
if (sum >= 1e9) sum -= 1e9;
}
}
return sum;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1091 ms |
2688 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1084 ms |
2816 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1085 ms |
4992 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1091 ms |
6136 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |