Submission #318597

# Submission time Handle Problem Language Result Execution time Memory
318597 2020-11-02T12:22:50 Z tengiz05 Stations (IOI20_stations) C++17
5 / 100
1000 ms 1232 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> edges[1005];
int dp[1005];
vector<bool> used;
void dfs(int u, int d=0){
	dp[u] = d;
	used[u] = true;
	for(auto v:edges[u]){
		if(used[v])continue;
		dfs(v,d+1);
	}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	for(int i=0;i<n;i++)edges[i].clear();
	for(int i=0;i<n-1;i++){
		edges[u[i]].push_back(v[i]);
		edges[v[i]].push_back(u[i]);
	}
	int mm=-1;
	for(int i=0;i<n;i++){
		if(edges[i].size() > 2)return u;
		if(edges[i].size() == 1)mm = i;
	}if(mm == -1)return vector<int>(0);
	used.assign(n,0);
	dfs(mm);
	vector<int> ans(n);
	for(int i=0;i<n;i++)ans[i] = dp[i];
	return ans;
}
/*

1
5 10
0 1
1 2
2 3
3 4
3
1 3 121
1 4 121
0 1 122

*/

int find_next_station(int s, int t, vector<int> c) {
	if(s <= t)return s+1;
	else return s-1;
}
# Verdict Execution time Memory Grader output
1 Correct 553 ms 1100 KB Output is correct
2 Correct 492 ms 1096 KB Output is correct
3 Correct 999 ms 1100 KB Output is correct
4 Correct 783 ms 948 KB Output is correct
5 Correct 777 ms 1080 KB Output is correct
6 Correct 556 ms 864 KB Output is correct
7 Correct 424 ms 1112 KB Output is correct
8 Correct 3 ms 940 KB Output is correct
9 Correct 4 ms 864 KB Output is correct
10 Correct 1 ms 1072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Invalid length of array as the response of 'label'. scenario=0, n=996, len=995
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 543 ms 1092 KB Output is correct
2 Correct 509 ms 1088 KB Output is correct
3 Correct 1000 ms 952 KB Output is correct
4 Correct 644 ms 952 KB Output is correct
5 Correct 584 ms 944 KB Output is correct
6 Correct 534 ms 896 KB Output is correct
7 Correct 477 ms 1120 KB Output is correct
8 Correct 3 ms 956 KB Output is correct
9 Correct 5 ms 864 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
11 Incorrect 1 ms 364 KB Invalid length of array as the response of 'label'. scenario=1, n=4, len=3
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 911 ms 952 KB Output is correct
2 Correct 654 ms 960 KB Output is correct
3 Correct 579 ms 944 KB Output is correct
4 Correct 2 ms 908 KB Output is correct
5 Correct 3 ms 864 KB Output is correct
6 Correct 1 ms 736 KB Output is correct
7 Incorrect 0 ms 492 KB Invalid length of array as the response of 'label'. scenario=0, n=4, len=3
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 548 ms 992 KB Output is correct
2 Correct 457 ms 1232 KB Output is correct
3 Correct 901 ms 736 KB Output is correct
4 Correct 637 ms 864 KB Output is correct
5 Correct 793 ms 1068 KB Output is correct
6 Correct 569 ms 984 KB Output is correct
7 Correct 436 ms 1112 KB Output is correct
8 Correct 3 ms 1080 KB Output is correct
9 Correct 6 ms 956 KB Output is correct
10 Correct 1 ms 864 KB Output is correct
11 Incorrect 1 ms 364 KB Invalid length of array as the response of 'label'. scenario=0, n=997, len=996
12 Halted 0 ms 0 KB -