Submission #432386

# Submission time Handle Problem Language Result Execution time Memory
432386 2021-06-18T08:59:16 Z milleniumEeee Stations (IOI20_stations) C++17
0 / 100
1 ms 584 KB
#ifndef EVAL
#include "stub.cpp"
#endif
#include "stations.h"
 
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pii pair<int, int>
#define pb push_back
#define szof(s) (int)s.size()
#define all(s) s.begin(), s.end()
 
using namespace std;
 
const int MAXN = 1005;
 
vector <int> G[MAXN]; // binary tree
vector <int> g[MAXN]; // cur component
 
void clean() {
	for (int i = 0; i < MAXN; i++) {
		g[i].clear();
	}
}

bool was_build = false;

int tin[MAXN], tout[MAXN], tiktak = 0;
int pr[MAXN];

void precalc(int v, int par) {
	pr[v] = par;
	tin[v] = ++tiktak;
	for (int to : G[v]) {
		if (to != par) {
			precalc(to, v);
		}
	}
	tout[v] = tiktak;
}

bool father(int a, int b) {
	return tin[a] <= tin[b] && tout[b] <= tout[a];
}

void build() {
	for (int i = 0; i < MAXN; i++) {
		G[i + 1].pb(i / 2);
		G[i / 2].pb(i + 1);
	}
	precalc(0, -1);
}
 
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	if (!was_build) {
		build();
		was_build = 1;
	}
	vector <int> labels(n);
	for (int i = 0; i < n; i++) {
		labels[i] = i;
	}
	return labels;
}
 
int find_next_station(int s, int t, vector<int> c) {
	// check s father t
	if (father(s, t)) {
		for (int el : c) {
			if (father(el, t)) {
				return el;
			}
		}
	} else {
		return (s - 1) / 2;		
	}
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:78:1: warning: control reaches end of non-void function [-Wreturn-type]
   78 | }
      | ^
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 584 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 472 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -