Submission #433046

# Submission time Handle Problem Language Result Execution time Memory
433046 2021-06-18T18:53:09 Z Ruba_K Stations (IOI20_stations) C++14
16 / 100
1043 ms 708 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 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.clear();

    for(int i = 0 ; i < n ; i ++)adj[i].clear();

    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 / 1000 == t / 1000){ 
        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:19:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int i = 0 ; i < adj[u].size() ; i ++){
      |                     ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 400 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=2004
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 368 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=1007
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 567 ms 504 KB Output is correct
2 Correct 498 ms 528 KB Output is correct
3 Correct 1043 ms 508 KB Output is correct
4 Correct 725 ms 492 KB Output is correct
5 Correct 656 ms 600 KB Output is correct
6 Correct 526 ms 504 KB Output is correct
7 Correct 550 ms 512 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 5 ms 472 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 582 ms 584 KB Output is correct
12 Correct 482 ms 628 KB Output is correct
13 Correct 480 ms 708 KB Output is correct
14 Correct 456 ms 508 KB Output is correct
15 Correct 64 ms 608 KB Output is correct
16 Correct 76 ms 552 KB Output is correct
17 Correct 114 ms 528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 913 ms 400 KB Output is correct
2 Correct 647 ms 400 KB Output is correct
3 Correct 450 ms 512 KB Output is correct
4 Correct 3 ms 472 KB Output is correct
5 Correct 4 ms 468 KB Output is correct
6 Correct 2 ms 480 KB Output is correct
7 Correct 555 ms 516 KB Output is correct
8 Correct 896 ms 564 KB Output is correct
9 Correct 638 ms 400 KB Output is correct
10 Correct 568 ms 508 KB Output is correct
11 Incorrect 1 ms 200 KB Invalid labels (duplicates values). scenario=5, label=1001
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 463 ms 528 KB Partially correct
2 Partially correct 411 ms 528 KB Partially correct
3 Correct 850 ms 400 KB Output is correct
4 Partially correct 589 ms 400 KB Partially correct
5 Partially correct 560 ms 400 KB Partially correct
6 Partially correct 442 ms 504 KB Partially correct
7 Partially correct 433 ms 528 KB Partially correct
8 Partially correct 3 ms 468 KB Partially correct
9 Partially correct 4 ms 468 KB Partially correct
10 Partially correct 2 ms 464 KB Partially correct
11 Incorrect 4 ms 328 KB Invalid labels (duplicates values). scenario=0, label=1009
12 Halted 0 ms 0 KB -