Submission #396866

#TimeUsernameProblemLanguageResultExecution timeMemory
396866biggRail (IOI14_rail)C++14
30 / 100
95 ms34244 KiB
#include "rail.h"
#include<bits/stdc++.h>
using namespace std;

const int MAXN = 5100;
int dist[MAXN][MAXN];

int getdistance(int i, int j){
	return getDistance(i,j);
}

void findLocation(int n, int first, int location[], int stype[])
{	
	location[0] = first, stype[0] = 1;
	if(n == 1) return;
	int fr, auxfr = 1e9 + 10; 
	for(int i = 1; i < n; i++){
		dist[0][i] = dist[i][0] = getdistance(0,i);
		if(dist[i][0] < auxfr) fr = i, auxfr = dist[i][0];

	}

	for(int i = 1; i < n; i++){
		if(i == fr){
			location[i] = first + dist[0][i];
			stype[i] = 2; 
		}else{
			dist[i][fr] = dist[fr][i] = getdistance(i, fr);
			if(dist[i][fr] == dist[0][i] - auxfr){
				location[i] = first - (dist[0][i] - 2*auxfr);
				stype[i] = 1;
			}else{
				location[i] = first + dist[0][i];
				stype[i] = 2;
			}
		}
	}
	return;
}

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:9:20: warning: 'fr' may be used uninitialized in this function [-Wmaybe-uninitialized]
    9 |  return getDistance(i,j);
      |         ~~~~~~~~~~~^~~~~
rail.cpp:16:6: note: 'fr' was declared here
   16 |  int fr, auxfr = 1e9 + 10;
      |      ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...