Submission #423410

# Submission time Handle Problem Language Result Execution time Memory
423410 2021-06-11T05:32:00 Z Belgutei Stations (IOI20_stations) C++17
0 / 100
1 ms 316 KB
#include "stations.h"

#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mk make_pair

vector<int> edge[1005];
bool visited[1005];

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	for(int i=0; i<n; i++) edge[i].clear();
	for(int i=0; i<n; i++) visited[i]=0;
	for(int i=0; i<u.size(); i++){
		edge[u[i]].pb(v[i]);
		edge[v[i]].pb(u[i]);
	}
	int pos=0;
	for(int i=0; i<n; i++){
		if(edge[i].size()==1){
			pos=i;
			break;
		}
	}
	std::vector<int> labels(n);
	int cnt=0;
	while(visited[pos]==0){
		cout<<pos<<" ";
		labels[pos]=cnt;
		visited[pos]=1;
		for(int i=0; i<edge[pos].size(); i++){
			if(visited[edge[pos][i]]==0){
				pos=edge[pos][i];
				break;
			}
		}
		cnt++;
	}
	/*
	cout<<"\n";
	for(int i=0; i<n; i++){
		cout<<labels[i]<<" ";
	}
	*/
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	if(c.size()==1){
		return c[0];
	}
	int mx=max(c[0],c[1]);
	int mn=min(c[0],c[1]);
	if(s>t) return mn;
	else return mx;
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:19:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |  for(int i=0; i<u.size(); i++){
      |               ~^~~~~~~~~
stations.cpp:36:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   for(int i=0; i<edge[pos].size(); i++){
      |                ~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 316 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 292 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 312 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -