# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
958978 |
2024-04-07T10:38:58 Z |
vjudge1 |
Ideal city (IOI12_city) |
C++17 |
|
1000 ms |
3144 KB |
//#include "city.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
const vector<pair<int, int>> dir = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};
int ans;
set<pair<int, int>> st, vis;
void bfs(int X, int Y) {
queue<tuple<int, int, int>> q;
q.push(make_tuple(0, X, Y));
while (!q.empty()) {
int d = get<0>(q.front());
int x = get<1>(q.front());
int y = get<2>(q.front());
q.pop();
if (vis.find(make_pair(x, y)) != vis.end()) continue;
vis.insert(make_pair(x, y));
ans += d;
for (auto [a, b] : dir) {
if (st.find(make_pair(x+a, y+b)) != st.end() &&
vis.find(make_pair(x+a, y+b)) == vis.end()) {
q.push(make_tuple(d+1, x+a, y+b));
}
}
}
}
int DistanceSum(signed N, signed *X, signed *Y) {
ans = 0;
for (int i = 0; i < N; i++) {
st.insert(make_pair(X[i], Y[i]));
}
for (int i = 0; i < N; i++) {
vis.clear();
bfs(X[i], Y[i]);
}
return ans/2;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
4 ms |
348 KB |
Output is correct |
5 |
Correct |
4 ms |
348 KB |
Output is correct |
6 |
Correct |
19 ms |
348 KB |
Output is correct |
7 |
Correct |
19 ms |
348 KB |
Output is correct |
8 |
Correct |
16 ms |
464 KB |
Output is correct |
9 |
Correct |
21 ms |
344 KB |
Output is correct |
10 |
Correct |
21 ms |
348 KB |
Output is correct |
11 |
Correct |
20 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
554 ms |
548 KB |
Output is correct |
2 |
Correct |
560 ms |
568 KB |
Output is correct |
3 |
Execution timed out |
1047 ms |
604 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1037 ms |
3140 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1062 ms |
3144 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |