답안 #316835

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
316835 2020-10-28T09:49:23 Z amunduzbaev 이상적인 도시 (IOI12_city) C++14
11 / 100
7 ms 1408 KB
//#include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int N=205, mod= 1e9;
int n, dist[N][N];
vector<vector<int>> edges(2005);

void Dijkstra(int cur){
	queue<int>q;
	q.push(cur);
	while(!q.empty()){
		int u=q.front(); q.pop();
		for(auto x:edges[u]){
			if(dist[cur][u]+1 < dist[cur][x]){
			dist[cur][x] = dist[cur][u]+1;
			q.push(x);
			}
		}
	}
}

int DistanceSum(int N, int *x, int *y) {
	n=N;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			dist[i][j]=2e9;
			dist[j][i]=2e9;
			if(abs(x[i]-x[j]) + abs(y[i]-y[j]) == 1){
				edges[i].pb(j);
				edges[j].pb(i);
			}
		}
	}

	for(int i=0;i<n;i++)
		Dijkstra(i);

	int ans=0;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			ans += dist[i][j];
			ans %= mod;
		}
	}
 	return ans;
}

/*

11
2 5
2 6
3 3
3 6
4 3
4 4
4 5
4 6
5 3
5 4
5 6

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 1408 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 1408 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -