Submission #432446

# Submission time Handle Problem Language Result Execution time Memory
432446 2021-06-18T10:03:35 Z milleniumEeee Stations (IOI20_stations) C++14
8 / 100
2433 ms 792 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 < 1005; i++) {
		G[i].clear();
	}
	for (int i = 0; i < 1000; 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) {
	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
	build();
	if (father(s, t)) {
		for (int el : c) {
			if (father(s, el) && 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 Incorrect 1247 ms 664 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1164 ms 656 KB Output is correct
2 Correct 1366 ms 656 KB Output is correct
3 Correct 2360 ms 708 KB Output is correct
4 Correct 1535 ms 668 KB Output is correct
5 Correct 1634 ms 668 KB Output is correct
6 Correct 1222 ms 656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1422 ms 656 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2433 ms 792 KB Output is correct
2 Incorrect 1837 ms 656 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1369 ms 656 KB Wrong query response.
2 Halted 0 ms 0 KB -