제출 #550701

#제출 시각아이디문제언어결과실행 시간메모리
550701CSQ31철로 (IOI14_rail)C++17
30 / 100
356 ms98432 KiB
#include <bits/stdc++.h>
#include "rail.h"
using namespace std;
int d[5001][5001];
void findLocation(int n, int f, int location[], int stype[])
{
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			d[i][j] = d[j][i] = getDistance(i,j);
		}
	}
	location[0] = f;
	stype[0] = 1;
	vector<int>mn(n,0);
	for(int i=0;i<n;i++){
		int c = 1e9;
		for(int j=0;j<n;j++){
			if(i==j)continue;
			if(c > d[i][j]){
				c = d[i][j];
				mn[i] = j;
			}
		}
	}
	int x = mn[0];
	stype[x] = 2;
	location[x] = d[x][0];
	for(int i=1;i<n;i++){
		if(mn[i] == 0){
			stype[i] = 2;
			location[i] = f + d[0][i];
		}
	}
	int c = 1e9;
	for(int i=0;i<n;i++){
		if(stype[i] == 2){
			if(c > location[i]){
				c = location[i];
				x = i;
			}
		}
	}
	for(int i=0;i<n;i++){
		if(!stype[i]){
			stype[i] = 1;
			location[i] = c-d[i][x];
			
		}
	}
	//for(int i=0;i<n;i++)cout<<stype[i]<<" "<<location[i]<<'\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...