Submission #432872

# Submission time Handle Problem Language Result Execution time Memory
432872 2021-06-18T14:25:11 Z lior5654 Stations (IOI20_stations) C++17
0 / 100
3000 ms 456 KB
#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();
    }
}

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

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:66:11: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   66 |  if(s < t && s < c[0] || s > t && s > c[0]) {
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:35:13: warning: control reaches end of non-void function [-Wreturn-type]
   35 |     vi res(n);
      |             ^
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 436 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 456 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3052 ms 200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3030 ms 200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 320 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -