Submission #19020

# Submission time Handle Problem Language Result Execution time Memory
19020 2016-02-17T04:51:31 Z suhgyuho_william Rail (IOI14_rail) C++
0 / 100
111 ms 692 KB
#include "rail.h"
#include <algorithm>

using namespace std;

int dis0[5010];
int disx[5010];
int bef[5010];
int op[5010],num[5010];
bool cmp(int x,int y){
	return dis0[x] < dis0[y];
}

void findLocation(int N, int first, int location[], int stype[]){
	int i,j;
	int small,x;
	int t,v,nv;
	int rear,tmp;

	location[0] = first; stype[0] = 1;
	small = 999999999;
    for(i=1; i<N; i++){
		dis0[i] = getDistance(0,i);
		if(small > dis0[i]){
			small = dis0[i];
			x = i;
		}
    }
    location[x] = first+dis0[i];
    stype[x] = 2;
	for(i=1; i<N; i++){
		if(i == x) continue;
		disx[i] = getDistance(x,i);
		if(dis0[i] == dis0[x]+disx[i]) op[i] = 2;
		else op[i] = 1;
	}
	rear = 0;
	for(i=1; i<N; i++){
		if(op[i] == 1){
			rear++;
			num[rear] = i;
		}
	}
	sort(num+1,num+rear+1,cmp);
	tmp = 0; bef[0] = -999999999;
	for(i=1; i<=rear; i++){
		v = num[i];
		t = getDistance(v,0);
		if(dis0[v] == t){
			location[v] = first+dis0[v];
			stype[v] = 2;
			bef[v] = tmp;
			tmp = v;
		}else{
			for(j=1; j<i; j++){
				nv = num[j];
				if(stype[nv] == 1) continue;
				location[v] = location[nv]-(t-dis0[nv]);
				if(location[bef[nv]] < location[v] && location[v] < location[nv]) break;
			}
			stype[v] = 1;
		}
	}
	rear = 0;
	for(i=1; i<N; i++){
		if(op[i] == 2){
			rear++;
			num[rear] = i;
		}
	}
	
}

Compilation message

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:29:15: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
     location[x] = first+dis0[i];
               ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 111 ms 644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 110 ms 692 KB Output isn't correct
2 Halted 0 ms 0 KB -