Submission #429445

# Submission time Handle Problem Language Result Execution time Memory
429445 2021-06-15T23:54:57 Z DanerZein Stations (IOI20_stations) C++14
10 / 100
1085 ms 3092 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.clear(); li.clear();
  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==t){
      hj=v; break;
    }
    if(v>s){
      pa=v;
      continue;
    }
    int aux=v/10;
    vector<int> hijo;
    while(aux!=0){
      hijo.push_back(aux%10);
      aux/=10;
    }
    reverse(hijo.begin(),hijo.end());
    for(int i=0;i<hijo.size();i++){
      int su=0;
      for(int j=i;j<hijo.size();j++){
	su*=10;
	su+=hijo[j];
	if(su==t){
	  hj=v;
	  break;
	}
      }
      if(hj!=-1) break;
    }
  }
  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++){
      |                   ~^~~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:63:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for(int i=0;i<hijo.size();i++){
      |                 ~^~~~~~~~~~~~
stations.cpp:65:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |       for(int j=i;j<hijo.size();j++){
      |                   ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 3008 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=1148210668
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 408 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=230144572
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 3092 KB Invalid labels (values out of range). scenario=1, k=1000000, vertex=0, label=-1366872140
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1085 ms 400 KB Output is correct
2 Correct 793 ms 492 KB Output is correct
3 Correct 729 ms 400 KB Output is correct
4 Correct 3 ms 476 KB Output is correct
5 Correct 5 ms 468 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 748 ms 424 KB Output is correct
8 Correct 1067 ms 480 KB Output is correct
9 Correct 810 ms 400 KB Output is correct
10 Correct 656 ms 476 KB Output is correct
11 Correct 7 ms 468 KB Output is correct
12 Correct 7 ms 468 KB Output is correct
13 Correct 4 ms 476 KB Output is correct
14 Correct 3 ms 464 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 576 ms 416 KB Output is correct
17 Correct 600 ms 428 KB Output is correct
18 Correct 569 ms 528 KB Output is correct
19 Correct 619 ms 528 KB Output is correct
20 Correct 652 ms 400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 3044 KB Invalid labels (values out of range). scenario=1, k=1000000000, vertex=1, label=-1676502435
2 Halted 0 ms 0 KB -