Submission #350152

# Submission time Handle Problem Language Result Execution time Memory
350152 2021-01-19T03:19:05 Z amunduzbaev Stations (IOI20_stations) C++14
0 / 100
3000 ms 2097156 KB
#include "stations.h"

#ifndef EVAL
#include "stub.cpp"
#endif

#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define all(x) x.begin(), x.end()

const int NN = 1e5+5;

vector<int> edges[NN];
int tim, val[NN];

void dfs(int u, int t, int p){
	if(t) val[u] = ++tim;
	for(auto x:edges[u]) if(x != p) dfs(x, t^1, u);
	if(!t) val[u] = ++tim;
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	for(int i=0;i<sz(u);i++){
		edges[u[i]].pb(v[i]);
		edges[v[i]].pb(u[i]);
	}
	dfs(0, 1, -1);
	vector<int> ans(n);
	for(int i=0;i<n;i++) ans[i] = val[i];
	//for(auto x:ans) cout<<x<<" ";
	//cout<<"\n";
	return ans;
}

int find_next_station(int s, int t, vector<int> c){
	sort(all(c));
	
	if(s < c[sz(c)-1]){
		int p = c[sz(c)-1];
		if(t >= p) { return p; }
		auto tmp = lower_bound(all(c), t);
		return (*tmp);
	}else{
		int p = c[0];
		if(t > s) { return p; }
		int i = sz(c)-1;
		while(c[i] > t && i > 0) i++;
		return c[i];
	}
	
}
# Verdict Execution time Memory Grader output
1 Runtime error 1328 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 Execution timed out 3052 ms 2924 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1397 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 872 ms 5660 KB Output is correct
2 Runtime error 1153 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2262 ms 2097156 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -