Submission #354547

# Submission time Handle Problem Language Result Execution time Memory
354547 2021-01-22T04:03:12 Z Dilshod_Imomov Stations (IOI20_stations) C++17
0 / 100
5 ms 876 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 1e3 + 7;

vector < int > adj[N];

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	std::vector<int> labels(n);
	for ( int i = 0; i < n; i++ ) {
		int x  = u[i], y = v[i];
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	vector < int > used(n + 1);
	while ( 1 ) {
		int rt = -1;
		for ( int i = 0; i < n; i++ ) {
			if ( adj[i].size() == 1 && !used[i] ) {
				rt = i;
				break;
			}
		}
		if ( rt == -1 ) {
			break;
		}
		int x = rt, num = 0;
		while ( 1 ) {
			labels[x] = num++;
			used[x] = 1;
			int ok = 1;
			for ( auto y: adj[x] ) {
				if ( !used[y] ) {
					x = y;
					ok = 0;
					break;
				}
			}
			if ( ok ) {
				break;
			}
		}
	}
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	if ( c.size() == 1 ) {
		return c[0];
	}
	if ( s < t ) {
		return c[1];
	}
	return c[0];
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 492 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 876 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 492 KB Invalid labels (duplicates values). scenario=1, label=111
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 820 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -