Submission #605359

#TimeUsernameProblemLanguageResultExecution timeMemory
605359MohamedAliSaidaneStations (IOI20_stations)C++14
0 / 100
5 ms336 KiB
#include <bits/stdc++.h>

    using namespace std;

    typedef long long ll;

    typedef pair<int,int> pii;
    typedef pair<ll,ll> pll;

    typedef vector<int> vi;
    typedef vector<ll> vll;
    typedef vector<pii> vpi;
    typedef vector<pll> vpl;

    #define pb push_back
    #define popb pop_back
    #define all(x) (x).begin(),(x).end()
    #define ff first
    #define ss second
    vi label(int n, int k, vi u, vi v)
    {
        vi rep;
        rep.assign(n, -1);
        vi adj[n];
        int head = 0;
        for(int i = 0; i < n - 1;i ++)
        {
            adj[u[i]].pb(v[i]);
            adj[v[i]].pb(u[i]);
        }
        for(int i=  0; i < n;i ++)
        {
            if(adj[i].size() == 1)
            {
                head = i;
                break;
            }
        }
        queue<pii> q;
        q.push({head, 0});
        while(!q.empty())
        {
            int node = q.front().ff;
            int d = q.front().ss;
            q.pop();
            rep[node] = d;
            for(auto e: adj[node])
            {
                if(rep[e] != -1)
                {
                    rep[e] = d + 1;
                    q.push({e, d + 1});
                }
            }
        }
        return rep;
    }
    int find_next_station(int s, int t, vi c)
    {
        if(s < t)
        {
            int maxi = c[0];
            for(auto e: c)
                maxi = max(maxi,e );
            return maxi;
        }
        else
        {
            int mini = c[0];
            for(auto e: c)
                mini = min(mini, e);
            return mini;
        }
    }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...