답안 #576442

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
576442 2022-06-13T06:12:42 Z benson1029 이상적인 도시 (IOI12_city) C++14
11 / 100
1000 ms 5476 KB
#include<bits/stdc++.h>
using namespace std;
map< pair<int,int>, int > mp, vis, dis;
queue< pair<int,int> > q;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};

int DistanceSum(int N, int *X, int *Y) {
	for(int i=0; i<N; i++) {
		mp[{X[i], Y[i]}] = 1;
	}
	long long ans = 0;
	for(int i=0; i<N; i++) {
		for(int j=0; j<N; j++) vis[{X[j], Y[j]}] = 0;
		vis[{X[i], Y[i]}] = 1;
		q.push({X[i], Y[i]});
		dis[{X[i], Y[i]}] = 0;
		while(!q.empty()) {
			int x = q.front().first;
			int y = q.front().second;
			ans += dis[{x, y}];
			q.pop();
			for(int j=0; j<4; j++) {
				if(mp[{x+dx[j], y+dy[j]}] == 1 && vis[{x+dx[j], y+dy[j]}] == 0) {
					vis[{x+dx[j], y+dy[j]}] = 1;
					dis[{x+dx[j], y+dy[j]}] = dis[{x, y}] + 1;
					q.push({x+dx[j], y+dy[j]});
				}
			}
		}
	}
	return (ans/2) % 1000000000;
}
# 결과 실행 시간 메모리 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 4 ms 212 KB Output is correct
5 Correct 5 ms 212 KB Output is correct
6 Correct 22 ms 352 KB Output is correct
7 Correct 23 ms 340 KB Output is correct
8 Correct 25 ms 340 KB Output is correct
9 Correct 22 ms 340 KB Output is correct
10 Correct 24 ms 340 KB Output is correct
11 Correct 25 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 903 ms 556 KB Output is correct
2 Correct 803 ms 524 KB Output is correct
3 Execution timed out 1069 ms 596 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1088 ms 4340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1073 ms 5476 KB Time limit exceeded
2 Halted 0 ms 0 KB -