제출 #605705

#제출 시각아이디문제언어결과실행 시간메모리
605705MohamedAliSaidane기지국 (IOI20_stations)C++14
100 / 100
1025 ms784 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

    const int nax = 1001;
    vi rep;
    int cureul = -1;
    vi adj[nax];
    int in[nax], out[nax];

    void dfs(int x, int d = 0, int p = -1)
    {
        in[x] = cureul++;
        for(auto e: adj[x])
            if(e != p)
                dfs(e, d + 1, x);
        out[x]  = cureul++;
        if(d & 1)
            rep[x]  = out[x];
        else
            rep[x] = in[x];
    }
    vi label(int n, int k, vi u, vi v)
    {
        for(int i = 0 ; i < n; i++)
            adj[i].clear();
        cureul = 0;
        rep.assign(n , 0);
        for(int i= 0; i < n - 1; i ++)
        {
            adj[u[i]].pb(v[i]);
            adj[v[i]].pb(u[i]);
        }
        dfs(0);
        vpi vec;
        for(int i =  0; i < n; i++)
        vec.pb({rep[i], i});
        sort(all(vec));
        for(int i = 0 ; i < n ;i++)
            rep[vec[i].ss]  = i;
        return rep;
    }
    int find_next_station(int s, int t, vi c)
    {

        sort(all(c));
        int sz = c.size();
        bool ev = s < c[0];
        int ini, outi;
        if(ev)
        {
            ini = s;
            if(s == 0)
                outi = 1999;
            else if(sz == 1)
                outi = ini + 1;
            else
                outi  = c[sz - 2] + 1;
            if(t >= ini && t <= outi)
            {
                for(auto e: c)
                    if(e >= t)
                        return e;
            }
            else
            {
                return c[sz - 1];
            }
        }
        else
        {
            outi = s;
            if(sz == 1)
                ini = outi;
            else
                ini = c[1] - 1;
            if(t >= ini && t <= outi)
            {
                reverse(all(c));
                for(auto e: c)
                    if(e <= t)
                        return e;
            }
            else
            {
                return c[0];
            }
        }

    }

컴파일 시 표준 에러 (stderr) 메시지

stations.cpp: In function 'int find_next_station(int, int, vi)':
stations.cpp:106:5: warning: control reaches end of non-void function [-Wreturn-type]
  106 |     }
      |     ^
#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...