Submission #306223

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

using namespace std;

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

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.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(s < t)return c.back();
		for(int i = 0; i < m; ++i){
			if(c[i] < t)return c[i];
		}
		return c.back();		
	}
	sort(c.begin(),c.end());
	if(s > t)return c.back();
	for(int i = 0; i < m; ++i){
		if(c[i] > t)return c[i];
	}
	return c.back();
	
}
# 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 3050 ms 3032 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1438 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 951 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 1250 ms 2097152 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -