Submission #1205242

#TimeUsernameProblemLanguageResultExecution timeMemory
1205242notmeStations (IOI20_stations)C++20
0 / 100
305 ms588 KiB
#include "stations.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int maxn = 2e3 + 10;
vector < int > g[maxn];

int tmr = 0;
int used[maxn];
int tin[maxn], tout[maxn];
void dfs(int beg, int from)
{
    used[beg] = 1;
        tmr ++;
    tin[beg] = tmr;
    for (auto nb: g[beg])
    {
        if(used[nb])continue;
        dfs(nb, beg);
    }
    tmr ++;
    tout[beg] = tmr;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v)
{
    memset(used, 0, sizeof(used));
    for (int i = 0; i < n; ++ i)
        g[i].clear();
    for (int i = 0; i < n; ++ i)
        tin[i] = tout[i] = 0;
    tmr = 0;
    for (int i = 0; i < n-1; ++ i)
    {
        g[u[i]].pb(v[i]);
        g[v[i]].pb(u[i]);
    }
    dfs(0, -1);
    std::vector<int> labels(n);
    for (int i = 0; i < n; i++)
    {
        labels[i] = i;
        //assert(labels[i] > 0);
    }
    return labels;
}

int find_next_station(int s, int t, std::vector<int> c)
{
    return c[0];
    int lst = c.back();

    if(lst > s)
    {

        int par = c.back();
        c.pop_back();
        if(t == par)return par;

        int bigger = 0, fst= 0;
        for (auto x: c)
        {
            if(x >= t)
            {
                bigger = 1;
                fst = x;
                continue;
            }
        }
        if(!bigger && t < s)return par;
        else if(bigger && t < s)return fst;
        else if(t > s)return par;

        return 0;
    }
    else
    {
        for (auto x: c)
        {
            if(x >= t)
                return x;
        }
    }
}
/**
2
7 100
0 1
0 2
0 6
2 3
2 4
3 5
4
6 3 0
4 1 2
3 4 2
4 3 2
7 100
0 1
0 2
0 6
2 3
2 4
3 5
4
6 3 0
1 3 0
3 4 2
4 3 2
*/
#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...