Submission #1059206

#TimeUsernameProblemLanguageResultExecution timeMemory
1059206c2zi6기지국 (IOI20_stations)C++14
76 / 100
552 ms1276 KiB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "stations.h"
 
VVI gp;
 
VI tin, tout;
int tc;
VI depth;
 
void dfs(int u, int p = -1) {
    tin[u] = tc++;
    for (int v : gp[u]) if (v != p) {
        depth[v] = depth[u]+1;
        dfs(v, u);
    }
    tout[u] = tc++;
}
 
VI label(int n, int k, VI U, VI V) {
    gp = VVI(n);
    rep(i, n-1) {
        int u = U[i];
        int v = V[i];
        gp[u].pb(v);
        gp[v].pb(u);
    }
    tc = 0;
    tin = tout = depth = VI(n);
    dfs(0);
 
    VI ret(n);
    rep(i, n) {
        if (depth[i]&1) ret[i] = tin[i];
        else ret[i] = tout[i];
    }
 
    /*rep(i, n) cout << i << ": " << tin[i] << ".." << tout[i] << endl;*/
    /*for (int x : ret) cout << x << " "; cout << endl;*/
    return ret;
}
 
bool isanc(int a, int b) {
    return a/1000 <= b/1000 && b%1000 <= a%1000;
}
 
int find_next_station(int s, int t, VI c) {
    if (c.size() == 1) return c[0];
    int n = c.size();
    int parent;
    int mytin, mytout;
    
    /*cout << "ME: " << s << endl;*/
    /*cout << "THEY: ";*/
    /*for (int x : c) cout << x << " ";*/
    /*cout << endl;*/
 
    bool they = (s < c[0]);
    /*
     * true - bolor@ tout en, es tin em
     * false - bolor@ tin en, es tout em
     */
    if (s == 0) {
        parent = -1;
    } else if (they) {
        parent = c[n-1];
        /*mytin = s;*/
        /*mytout = c[n-2]+1;*/
        /*if (t < mytin || t > mytout) return parent;*/
        if (s <= t && t <= c[n-2]);
        else return parent;
    } else {
        parent = c[0];
        /*mytin = c[1]-1;*/
        /*mytout = s;*/
        /*if (t < mytin || t > mytout) return parent;*/
        if (c[1] <= t && t <= s);
        else return parent;
    }

    if (they) {
        for (int x : c) if (x != parent) {
            if (x >= t) return x;
        }
    } else {
        reverse(all(c));
        for (int x : c) if (x != parent) {
            if (x <= t) return x;
        }
    }
    return parent;
 
}
 
 

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, VI)':
stations.cpp:80:9: warning: unused variable 'mytin' [-Wunused-variable]
   80 |     int mytin, mytout;
      |         ^~~~~
stations.cpp:80:16: warning: unused variable 'mytout' [-Wunused-variable]
   80 |     int mytin, mytout;
      |                ^~~~~~
#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...