Submission #429402

# Submission time Handle Problem Language Result Execution time Memory
429402 2021-06-15T22:53:51 Z DanerZein Stations (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));
  }
  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;
    while(aux!=0){
      if(aux%10==t){
	hj=v; break;
      }
      aux/=10;
    }
  }
  if(hj==-1) return pa;
  return hj;
}

Compilation message

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:11:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |       for(int i=0;i<li[v].size();i++){
      |                   ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 328 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3127 ms 1135444 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1466 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Invalid labels (values out of range). scenario=2, k=1000000000, vertex=0, label=2115727814
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3168 ms 1264024 KB Time limit exceeded
2 Halted 0 ms 0 KB -