# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1005906 |
2024-06-23T07:44:16 Z |
정민찬(#10832) |
Ideal city (IOI12_city) |
C++14 |
|
1000 ms |
4956 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9;
int N;
vector<int> adj[100010];
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
ll getDist(int st) {
vector<int> d(N, -1);
d[st] = 0;
ll ans = 0;
queue<int> q;
q.push(st);
while (!q.empty()) {
auto x = q.front();
q.pop();
ans += d[x];
for (auto &nx : adj[x]) {
if (d[nx] == -1) {
d[nx] = d[x] + 1;
q.push(nx);
}
}
}
return ans;
}
int DistanceSum(int _N, int *X, int *Y) {
N = _N;
map<pair<int,int>, int> mp;
for (int i=0; i<N; i++) {
mp[{X[i], Y[i]}] = i;
}
for (int i=0; i<N; i++) {
for (int k=0; k<4; k++) {
int nx = X[i] + dx[k];
int ny = Y[i] + dy[k];
if (mp.find({nx, ny}) != mp.end()) {
adj[i].push_back(mp[{nx, ny}]);
}
}
}
ll ans = 0;
for (int i=0; i<N; i++) {
ans += getDist(i);
ans %= mod;
}
return ans / 2;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
2652 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
1 ms |
2648 KB |
Output is correct |
6 |
Correct |
1 ms |
2652 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
2652 KB |
Output is correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
1 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
2648 KB |
Output is correct |
2 |
Correct |
9 ms |
2652 KB |
Output is correct |
3 |
Correct |
20 ms |
2908 KB |
Output is correct |
4 |
Correct |
24 ms |
2908 KB |
Output is correct |
5 |
Correct |
34 ms |
3024 KB |
Output is correct |
6 |
Correct |
35 ms |
3004 KB |
Output is correct |
7 |
Correct |
43 ms |
2908 KB |
Output is correct |
8 |
Correct |
41 ms |
2908 KB |
Output is correct |
9 |
Correct |
36 ms |
2908 KB |
Output is correct |
10 |
Correct |
38 ms |
3000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1018 ms |
4952 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1058 ms |
4956 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |