이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "stations.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std ;
const int N = 1e3 + 3 ;
vector<int> adj[N];
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<int> labels(n);
for(int i = 0 ;i < n; i ++)adj[i].clear();
// clear
for(int i = 0 ; i < n - 1 ; i ++){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
for(int i = 0 ; i < n ; i ++){
string s = "" ;
for(auto f : adj[i])s.push_back(f + 48);
s.push_back(i + 48);
while(s.size() < 8)s.insert(0 , "9");
labels[i] = stoi(s);
}
return labels;
}
int find_next_station(int s, int t,vector<int> c) {
if(c.size() == 1)return c[0];
for(auto f : c){
map<int , int > mp ;
int tmp ;
tmp = t ;
while(tmp){
mp[tmp % 10] ++ ;
tmp /= 10;
}
mp.erase(9);
tmp = f ;
while(tmp){
if(mp.count(tmp % 10) && tmp % 10 != s % 10){
return f ;
}
tmp /= 10 ;
}
}
return c[0];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |