답안 #330343

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
330343 2020-11-24T20:40:49 Z marvenlee 기지국 (IOI20_stations) C++14
0 / 100
1083 ms 868 KB
#include "stations.h"
#include <vector>
#include <iostream>
using namespace std;

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {


	std::vector<int> labels(n);
    vector< vector<int> > graph(n,vector<int>());
    for(int i=0;i<n-1;i++){
        graph[u[i]].push_back(v[i]);
        graph[v[i]].push_back(u[i]);
    }
    int s=0;
    for(int i=0;i<n;i++){
        if(graph[i].size()==1) {s=i;break;}
    }
    int ns=s,b=s;

    for(int i=0;i<n;i++){


        labels[s]=i;
        //printf("%dst: %d, labels[s]:%d\n",i,s,labels[s]);


        for(auto j=graph[b].begin(); j!=graph[b].end();j++){
            if(*j!=b){
               b=s;
               s=ns;
               ns=*j;
            }
        }
    }
    //for(int i=0;i<n-1;i++) cout << labels[i] << " ";
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
    if(c.size()==2){
    if(c[0]>c[1]){
        int temp=c[0];
        c[0]=c[1];
        c[1]=temp;
    }
        return (s<t)?c[1]:c[0];
    }
    else return c[0];
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1083 ms 868 KB Output is correct
2 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -