제출 #73949

#제출 시각아이디문제언어결과실행 시간메모리
73949Hoget157철로 (IOI14_rail)C++14
30 / 100
87 ms1052 KiB
#include "rail.h"
#include <bits/stdc++.h>
#define INF 1e+9
using namespace std;

typedef pair<int,int> P;

void findLocation(int n, int first, int location[], int stype[]){
	location[0] = first;
	stype[0] = 1;
	if(n == 1) return;
	if(n == 2){
		int d = getDistance(0,1);
		location[1] = first + d;
		stype[1] = 2;
		return;
	}
	int d0[5010] = {},d1[5010] = {},mi = INF,mii;
	for(int i = 1;i < n;i++){
		d0[i] = getDistance(0,i);
		if(mi > d0[i]){
			mi = d0[i];
			mii = i;
		}
	}
	for(int i = 0;i < n;i++){
		if(mii != i) d1[i] = getDistance(mii,i);
	}
	for(int i = 1;i < n;i++){
		if(i != mii && d0[i] > d1[i]){
			stype[i] = 1;
			location[i] = first - (d0[i] - 2 * d0[mii]);
		}
		else{
			stype[i] = 2;
			location[i] = first + d0[i];
		}
	}
	//for(int i = 0;i < n;i++) cout << stype[i] << " " << location[i] << endl;
}

컴파일 시 표준 에러 (stderr) 메시지

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:30:3: warning: 'mii' may be used uninitialized in this function [-Wmaybe-uninitialized]
   if(i != mii && d0[i] > d1[i]){
   ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...