Submission #432873

#TimeUsernameProblemLanguageResultExecution timeMemory
432873lior5654Stations (IOI20_stations)C++17
5 / 100
926 ms636 KiB
#include <bits/stdc++.h>

using namespace std;


typedef long long int ll;
typedef pair<ll, ll> pl;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
typedef vector<vpl> vvpl;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<vpi> vvpi;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(c) (c.begin()), (c.end())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second


#include "stations.h"


const int maxn = 1e3 + 5;

vi g[maxn];


std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
    vi res(n);

    rep(i, n-1) {
        g[u[i]].pb(v[i]);
        g[v[i]].pb(u[i]);
    }
    int fir = -1;
    for(int i = 0; i < n; ++i) {
        if(g[i].size() == 1) {
            fir = i; break;
        }
    }
 
    assert(fir != -1);
    int pre = -1;
    int cur = fir;
    rep(i, n) {
        res[cur] = i;
        for(auto e : g[cur]) {
            if(e!=pre) {
                pre = cur; cur = e; break;
            }
        }
    }

    rep(i, n) {
        g[i].clear();
    }
    return res;
}

int find_next_station(int s, int t, std::vector<int> c) {
	if(s < t && s < c[0] || s > t && s > c[0]) {
        return c[0];
    } else {
        return c[1];
    }
}

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:67:11: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   67 |  if(s < t && s < c[0] || s > t && s > c[0]) {
#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...