Submission #306227

# Submission time Handle Problem Language Result Execution time Memory
306227 2020-09-24T23:24:37 Z sofapuden Stations (IOI20_stations) C++14
0 / 100
3000 ms 256164 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

vector<vector<int>> gri;
vector<int> ret;
int cn;

void dfs(int x, int p, int d){
	if(d&1)ret[x] = cn++;
	for(auto i : gri[x]){
		if(i == p)continue;
		dfs(i,x,d+1);
	}
	if(!(d&1))ret[x] = cn++;	
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	gri.clear();
	ret.clear();
	cn = 0;
	gri.resize(n);
	for(int i = 0; i < n; ++i){
		gri[u[i]].push_back(v[i]);
		gri[v[i]].push_back(u[i]);
	}
	ret.resize(n);
	dfs(0,0,0);
	return ret;
}

int find_next_station(int s, int t, vector<int> c) {
	int m = c.size();
	if(m == 1)return c[0];
	for(int i : c)if(i == t)return t;
	if(s < c[0]){
		sort(c.rbegin(),c.rend());
		if(t < s)return c[0];
		for(int i = 0; i < m; ++i){
			if(c[i] > t)return c[i];
		}
		return c[0];		
	}
	sort(c.begin(),c.end());
	if(s < t)return c[0];
	for(int i = 0; i < m; ++i){
		if(c[i] < t)return c[i];
	}
	return c[0];
	
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3079 ms 256164 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 985 ms 776 KB Output is correct
2 Runtime error 1 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -