Submission #728344

# Submission time Handle Problem Language Result Execution time Memory
728344 2023-04-22T08:41:38 Z NeroZein Dreaming (IOI13_dreaming) C++17
0 / 100
20 ms 4052 KB
#include "dreaming.h"
#include <bits/stdc++.h>

using namespace std; 

const int NN = 3003;

int a[NN], b[NN], t[NN];
vector<pair<int, int>> g[NN]; 
int vis[NN]; 
int far[NN]; 

int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
  int n, m, l;
  n = N, m = M, l = L; 
  for (int i = 0; i < m; ++i) {
    a[i] = A[i];
    b[i] = B[i];
    t[i] = T[i];
  }
  for (int i = 0; i < m; ++i) { 
    g[a[i]].emplace_back(b[i], t[i]);
    g[b[i]].emplace_back(a[i], t[i]); 
  }
  int ncc = 0; 
  function<void(int, int)> pre = [&](int v, int p) {
    vis[v] = ncc; 
    for (auto it : g[v]) {
      int u = it.first;
      if (!vis[u]) {
        pre(u, v); 
      }
    }
  };
  for (int i = 0; i < n; ++i) {
    if (!vis[i]) {
      ncc++; 
      pre(i, i); 
    }
  }
  function<void(int, int, int, int)> Dfs = [&](int v, int p, int rt, int mx) {
    far[v] = max(far[v], mx); 
    for (auto it : g[v]) {
      int u = it.first;
      int w = it.second; 
      if (u != p) {
        Dfs(u, v, rt, mx + w); 
      }
    }
  };
  for (int i = 0; i < n; ++i) {
    Dfs(i, i, i, 0); 
  }
  vector<int> fc(ncc + 1, 1e9); 
  for (int i = 0; i < n; ++i) {
    fc[vis[i]] = min(fc[vis[i]], far[i]); 
  }
  int ans = fc[1] + fc[2] + 2;
  return ans; 
}

Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:14:13: warning: variable 'l' set but not used [-Wunused-but-set-variable]
   14 |   int n, m, l;
      |             ^
# Verdict Execution time Memory Grader output
1 Runtime error 20 ms 4052 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 20 ms 4052 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 13 ms 1772 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 20 ms 4052 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -