Submission #354545

# Submission time Handle Problem Language Result Execution time Memory
354545 2021-01-22T03:58:12 Z Dilshod_Imomov Stations (IOI20_stations) C++17
0 / 100
1025 ms 992 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);
	}
	int rt = 0;
	for ( int i = 0; i < n; i++ ) {
		if ( adj[i].size() == 1 ) {
			rt = i;
			break;
		}
	}
	int cnt = 0, x = rt, num = 0;
	vector < int > used(n + 1);
	while ( num < n ) {
		labels[x] = num++;
		used[x] = 1;
		for ( auto y: adj[x] ) {
			if ( !used[y] ) {
				x = y;
			}
		}
	}
	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];
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:24:6: warning: unused variable 'cnt' [-Wunused-variable]
   24 |  int cnt = 0, x = rt, num = 0;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 492 KB Invalid labels (duplicates values). scenario=3, 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 620 KB Invalid labels (duplicates values). scenario=2, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1025 ms 992 KB Output is correct
2 Incorrect 770 ms 952 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 620 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -