Submission #373577

# Submission time Handle Problem Language Result Execution time Memory
373577 2021-03-05T06:48:16 Z Jarif_Rahman Stations (IOI20_stations) C++17
0 / 100
1061 ms 864 KB
#include "stations.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
vector<vector<int>> v;
vector<int> lb;
pair<int, int> div(int x){
    int y = 1<<10;
    pair<int, int> r = {x/10, x%10};
    return r;
}
void dfs(int nd, int ss, int a, int b){
    lb[nd] = a+b;
    int sz = v[nd].size();
    if(ss == -1) sz++;
    if(sz > 1){
        for(int i = 0; i < 10; i++){
            if(!(a&(1<<i))){
                a+=1<<i;
                break;
            }
        }
    }
    b++;
    for(int x: v[nd]) if(x != ss) dfs(x, nd, a, b++);
}
vector<int> label(int n, int k, vector<int> aa, vector<int> bb){
    v.assign(n, {});
    lb.resize(n);
    for(int i = 0; i < n-1; i++){
        v[aa[i]].pb(bb[i]);
        v[bb[i]].pb(aa[i]);
    }
    dfs(0, -1, 0, 0);
    return lb;
}
int find_next_station(int s, int t, vector<int> c){
    auto a = div(s), b = div(t);
    if(a.f != b.f){
        if((a.f&b.f) == a.f){
            for(int x: c){
                auto cc = div(x);
                if(a.sc > cc.sc) continue;
                if((cc.f&b.f) == cc.f) return x;
            }
        }
        for(int x: c){
            auto cc = div(x);
            if(a.sc > cc.sc) return x;
        }
    }
    if(a.sc > b.sc){
        for(int x: c){
            auto cc = div(x);
            if(a.sc > cc.sc) return x;
        }
    }
    else{
        for(int x: c){
            auto cc = div(x);
            if(a.sc > cc.sc) continue;
            if((cc.f&b.f) == cc.f) return x;
        }
    }
    return 0;
}

Compilation message

stations.cpp: In function 'std::pair<int, int> div(int)':
stations.cpp:12:9: warning: unused variable 'y' [-Wunused-variable]
   12 |     int y = 1<<10;
      |         ^
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 492 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=2, label=1076
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 492 KB Invalid labels (duplicates values). scenario=0, label=6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 492 KB Invalid labels (duplicates values). scenario=1, label=1090
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1061 ms 764 KB Output is correct
2 Incorrect 728 ms 864 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 492 KB Invalid labels (duplicates values). scenario=1, label=1197
2 Halted 0 ms 0 KB -