Submission #433127

# Submission time Handle Problem Language Result Execution time Memory
433127 2021-06-18T21:59:56 Z Ruba_K Stations (IOI20_stations) C++14
0 / 100
881 ms 512 KB
#include "stations.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std ;


const int N = 1e3 + 3 ;
vector<int> adj[N];
map<int , int > fd ;

int now ;

void dfs(int u , int p , int d){
    if(d > 3)return ;

    fd[u] = now ;



    for(auto f : adj[u]){
        if(f != p)
            dfs(f , u , d + 1);


    }


}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
    vector<int> labels(n);
    fd.clear();
    for(int i = 0 ;i < n; i ++)adj[i].clear();

    // 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() == 1)
            now = i , dfs(i , -1 , 0);

    }



    for(int i = 0 ; i < n ; i ++){

        string s = "" ;


        for(auto f : adj[i])s.push_back(f + 48);
        s.push_back(fd[i] + '0');

        s.push_back(i + 48);

        while(s.size() < 9)s.insert(0 , "9");
        if(s[0] == '0')swap(s[0] , s[1]);

        labels[i] = stoi(s);

    }





	return labels;
}

int find_next_station(int s, int t,vector<int> c) {

    if(c.size() == 1)return c[0];

        for(auto f : c)if(f == t)return f ;


     for(auto f : c){

        //cout << s <<  " " << t << " " << f << endl ;
        map<int , int > mp ;

        int tmp  ;
        tmp = t ;

        int idx = -1 ;

        while(tmp){
            idx ++ ;

            if(idx != 1)mp[tmp % 10] ++ ;

            tmp /= 10;
        }
             mp.erase(9);

        tmp = f ;
        idx = -1 ;
        while(tmp){
            idx ++ ;
            if(idx != 1 && mp.count(tmp % 10)  ){
                    return f ;
            }

            tmp /= 10 ;

        }




     }
   //reverse(c.begin() , c.end());
    string str = to_string(c[0]);

    int a = str[7] - '0';
    int ok = 0 ;

    int tmp = c[0];
    tmp /= 100 ;

    while(tmp){

        if(tmp % 10 == a)ok ++ ;

        tmp /= 10 ;

    }

    if(!ok)return c[1];
     else if(a == t % 10  )return c[0];
     else return c[1];






}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 328 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=999999690
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 328 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=999991200
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 408 KB Invalid labels (values out of range). scenario=0, k=1000000, vertex=0, label=999999110
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 881 ms 400 KB Output is correct
2 Correct 666 ms 512 KB Output is correct
3 Correct 630 ms 512 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Incorrect 4 ms 468 KB Wrong query response.
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 412 KB Invalid labels (duplicates values). scenario=1, label=99999
2 Halted 0 ms 0 KB -