Submission #433039

# Submission time Handle Problem Language Result Execution time Memory
433039 2021-06-18T18:47:13 Z Ruba_K Stations (IOI20_stations) C++14
0 / 100
3000 ms 2097156 KB
#include "stations.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std ;


const int N = 1e3 + 3 ;
vector<int> labels;
vector<int> adj[N];


int getlog(int i){

    return log2(i + 1);



}
int st = 0 ;
void dfs(int u , int p , int l){

    if(st != u)
        labels[u] = l ;
    else labels[u] = 0 ;

    for(int i = 0 ; i < adj[u].size() ; i ++){
        auto f = adj[u][i];

        if(f != p){

            if(u == st)dfs(f , u , 1e3 * (i + 1));
            else dfs(f , u , l + 1);


        }

    }



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

    labels.resize(n);



    // 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 ++)
        if(adj[i].size() > 2)st = i ;

    dfs(st , -1 , 0);


	return labels;
}

int find_next_station(int s, int t,vector<int> c) {
     
    if(s / 1e3 == t / 1e3){
        if(s > t)return s - 1 ;
        else return s + 1 ;


    }
    else if(s == 0)return (t / 1000) * 1000 ;
    else return(s % 1000 == 0 ? 0 : s - 1);


	return c[0];
}

Compilation message

stations.cpp: In function 'void dfs(int, int, int)':
stations.cpp:26:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i = 0 ; i < adj[u].size() ; i ++){
      |                     ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1724 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3030 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1548 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 916 ms 400 KB Output is correct
2 Runtime error 1163 ms 2097156 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2789 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -