Submission #761624

# Submission time Handle Problem Language Result Execution time Memory
761624 2023-06-20T05:49:51 Z SanguineChameleon Ideal city (IOI12_city) C++17
11 / 100
1000 ms 1876 KB
#include <bits/stdc++.h>
using namespace std;

const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};

int DistanceSum(int N, int *X, int *Y) {
	int res = 0;
	for (int i = 0; i < N; i++) {
		map<pair<int, int>, int> dist;
		for (int j = 0; j < N; j++) {
			if (j != i) {
				dist[make_pair(X[j], Y[j])] = 0;
			}
		}
		dist[make_pair(X[i], Y[i])] = 1;
		deque<pair<int, int>> Q;
		Q.emplace_back(X[i], Y[i]);
		while (!Q.empty()) {
			int cx = Q.front().first;
			int cy = Q.front().second;
			Q.pop_front();
			int cur = dist[make_pair(cx, cy)];
			res += cur - 1;
			for (int d = 0; d < 4; d++) {
				int nx = cx + dx[d];
				int ny = cy + dy[d];
				auto it = dist.find(make_pair(nx, ny));
				if (it != dist.end() && it->second == 0) {
					dist[make_pair(nx, ny)] = cur + 1;
					Q.emplace_back(nx, ny);
				}
			}
		}
	}
	return res / 2;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 3 ms 308 KB Output is correct
5 Correct 3 ms 212 KB Output is correct
6 Correct 11 ms 216 KB Output is correct
7 Correct 12 ms 324 KB Output is correct
8 Correct 12 ms 320 KB Output is correct
9 Correct 13 ms 320 KB Output is correct
10 Correct 13 ms 308 KB Output is correct
11 Correct 13 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 453 ms 364 KB Output is correct
2 Correct 428 ms 360 KB Output is correct
3 Execution timed out 1077 ms 340 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1058 ms 1876 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 1876 KB Time limit exceeded
2 Halted 0 ms 0 KB -