Submission #985486

# Submission time Handle Problem Language Result Execution time Memory
985486 2024-05-18T00:58:14 Z Alex0x0 Stations (IOI20_stations) C++14
0 / 100
3 ms 772 KB
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
// #pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef int lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
typedef vector<ii> vii;
#define deb(x) cout << #x": " << (x) << endl;

vector <vi> adj;

vi tk;
lli curVis = 0;

void dfs(lli u){
  tk[u] = curVis++;
  for (auto & i : adj[u]){
    if (tk[i] == -1) dfs(i);
  }
}

vi label(lli n, lli k, vi u, vi v){
  adj.resize(n + 5, {});
  tk.resize(n, -1ll);
  curVis = 0;
  fore(i,0,n-1){
    adj[u[i]].pb(v[i]);
    adj[v[i]].pb(u[i]);
    // cout << u[i] << ' ' << v[i] << ENDL;
  }
  lli lst = 0;
  fore(i,0,n) if (sz(adj[i]) == 1) lst = i;
  // fore(i,0,n) cout << i << ": " << sz(adj[i]) << ENDL;
  dfs(lst);
  return tk;
}


lli find_next_station(lli s, lli t, vi c){
  if (t > s) return s + 1;
  return s - 1;
}

// int main(){ _
//   // freopen("file.in","r",stdin);
//   // freopen("file.out","w",stdout);
//   vector<vi> vv;
//   lli t; cin >> t;
//   while (t--){
//     lli n, k; cin >> n >> k;
//     vi a(n-1); vi b(n-1);
//     fore(i,0,n-1) cin >> a[i] >> b[i];
//     vi v = label(n, k, a, b);
//     for (auto & i : v) cout << i << ' '; cout << ENDL;
//     vv.pb(v);
//   }
//   return 0;
// }
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 528 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 604 KB Invalid labels (values out of range). scenario=3, k=1000, vertex=991, label=-1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 772 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 588 KB Invalid labels (values out of range). scenario=1, k=1000000000, vertex=5, label=-1
2 Halted 0 ms 0 KB -