답안 #429421

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
429421 2021-06-15T23:17:19 Z DanerZein 기지국 (IOI20_stations) C++14
0 / 100
3000 ms 2097156 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
vector<vi> G;
vector<vi> li;
void dfs(int u,int p){
  for(auto &v:G[u]){
    if(v!=p){
      dfs(v,u);
      for(int i=0;i<li[v].size();i++){
	li[u].push_back(li[v][i]);
      }
    }
  }
  li[u].push_back(u);
}
int construct(int id){
  int s=0;
  int e=1;
  for(int i=li[id].size()-1;i>=0;i--){
    s+=(li[id][i]*e);
    e*=10;
  }
  return s;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
  G.resize(n+1);
  li.resize(n+1);
  for(int i=0;i<n-1;i++){
    G[u[i]].push_back(v[i]);
    G[v[i]].push_back(u[i]);
  }
  dfs(0,-1);
  vector<int> lab;
  for(int i=0;i<n;i++){
    lab.push_back(construct(i));
    //cout<<lab[i]<<" ";
  }
  //cout<<endl;
  return lab;
}

int find_next_station(int s, int t, std::vector<int> c) {
  int pa=-1;
  int hj=-1;
  for(auto &v:c){
    if(v>s){
      pa=v;
      continue;
    }
    int aux=v;
    int e=10;
    for(int i=0;i<8;i++){
      int a,b;
      a=aux%e; b=aux/e;
      e*=10;
      if(a==t || b==t) hj=v;
    }
  }
  //cout<<s<<" "<<t<<" "<<hj<<" "<<pa<<endl;
  if(hj==-1) return pa;
  return hj;
}

Compilation message

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:12:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |       for(int i=0;i<li[v].size();i++){
      |                   ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 412 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3177 ms 1168348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1533 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 292 KB Invalid labels (values out of range). scenario=2, k=1000000000, vertex=0, label=2115727814
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3174 ms 1280268 KB Time limit exceeded
2 Halted 0 ms 0 KB -