Submission #1062596

# Submission time Handle Problem Language Result Execution time Memory
1062596 2024-08-17T08:57:57 Z jamjanek Stations (IOI20_stations) C++14
0 / 100
3000 ms 2097152 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;

vector<int>graf[1010];
int pre[1010], it=-1, post[1010];
void dfs(int x, int o){
	pre[x] = ++it;
	for(auto j: graf[x])
		if(j!=o)
			dfs(j, x);
	post[x] = it;
}
vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	int i;
	for(i=0;i<n-1;i++){
		graf[u[i]].push_back(v[i]);
		graf[v[i]].push_back(u[i]);
	}
	it= -1;
	dfs(0, 0);
	std::vector<int> labels(n);
	for (int i = 0; i < n; i++) {
		labels[i] = 1000*pre[i]+post[i];
	}
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	int pre1, post1, pre2, post2;
	pre1 = s/1000;post1 = s%1000;
	pre2 = t/1000;post2 = t%1000;
	int ojciec;
	for(auto j: c){
		int pre3 = j/1000, post3 = j%1000;
		if(pre3<pre1){
			ojciec = j;
			continue;
		}
		if(pre3<=pre2 && pre2<=post3)
			return j;
	}
	return ojciec;
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:30:12: warning: variable 'post1' set but not used [-Wunused-but-set-variable]
   30 |  int pre1, post1, pre2, post2;
      |            ^~~~~
stations.cpp:30:25: warning: variable 'post2' set but not used [-Wunused-but-set-variable]
   30 |  int pre1, post1, pre2, post2;
      |                         ^~~~~
stations.cpp:33:6: warning: 'ojciec' may be used uninitialized in this function [-Wmaybe-uninitialized]
   33 |  int ojciec;
      |      ^~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1274 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3057 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1295 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 553 ms 800 KB Output is correct
2 Runtime error 1100 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2130 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -