Submission #1078547

# Submission time Handle Problem Language Result Execution time Memory
1078547 2024-08-27T20:02:35 Z avighna Arcade (NOI20_arcade) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>

typedef long long ll;

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);

  ll n, m;
  std::cin >> n >> m;
  std::vector<ll> t(m), a(m);
  for (auto &i : t) {
    std::cin >> i;
  }
  for (auto &i : a) {
    std::cin >> i;
  }

  std::vector<std::vector<ll>> adj(m);
  std::vector<ll> indeg(m), outdeg(m);
  for (ll i = 0; i < m; ++i) {
    for (ll j = 0; j < m; ++j) {
      if (i == j) {
        continue;
      }
      if (std::abs(a[i] - a[j]) <= t[j] - t[i]) {
        adj[i].push_back(j);
        // std::cout << i << ", " << j << '\n';
        outdeg[i]++, indeg[j]++;
      }
    }
  }
  std::function<ll(ll)> dfs;
  std::vector<bool> vis(n);
  bool bad = false;
  dfs = [&](ll node) {
    if (vis[node]) {
      bad = true;
      return ll(-1e15);
    }
    vis[node] = true;
    ll ans = 0;
    for (auto &i : adj[node]) {
      ans += dfs(i);
    }
    return std::max(ans, 1LL);
  };

  ll ans = 0;
  for (ll i = 0; i < m; ++i) {
    if (indeg[i] == 0) {
      ll cur = dfs(i);
      if (!bad) {
        ans += cur;
      } else {
        bad = false;
      }
    }
  }
  std::cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -