Submission #1093147

# Submission time Handle Problem Language Result Execution time Memory
1093147 2024-09-26T03:21:24 Z juicy Stranded Far From Home (BOI22_island) C++17
10 / 100
309 ms 524288 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int N = 2e5 + 5;

int n, m;
int a[N], pr[N];
long long s[N];
bool lose[N];

int find(int u) {
  if (u == pr[u]) {
    return u;
  }
  int p = find(pr[u]);
  lose[u] |= lose[pr[u]];
  return pr[u] = p;
}

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

  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    pr[i] = i, s[i] = a[i];
  }
  vector<array<int, 2>> e;
  while (m--) {
    int x, y; cin >> x >> y;
    if (a[x] > a[y]) {
      swap(x, y);
    }
    e.push_back({x, y});
  }
  sort(e.begin(), e.end(), [&](const auto &i, const auto &j) {
    return a[i[1]] < a[j[1]];
  });
  for (auto [u, v] : e) {
    u = find(u);
    if (u ^ v) {
      lose[u] = s[u] < a[v];
      pr[u] = v;
      s[v] += s[u];
    }
  }
  for (int i = 1; i <= n; ++i) {
    find(i);
    cout << (lose[i] ? 0 : 1);
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 472 KB Output is correct
6 Runtime error 285 ms 524288 KB Execution killed with signal 9
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 67 ms 10064 KB Output is correct
4 Correct 51 ms 8672 KB Output is correct
5 Correct 64 ms 9668 KB Output is correct
6 Correct 65 ms 9928 KB Output is correct
7 Correct 68 ms 10044 KB Output is correct
8 Correct 61 ms 9928 KB Output is correct
9 Correct 67 ms 9920 KB Output is correct
10 Correct 45 ms 9160 KB Output is correct
11 Correct 51 ms 9928 KB Output is correct
12 Correct 53 ms 8648 KB Output is correct
13 Correct 46 ms 8392 KB Output is correct
14 Correct 58 ms 8616 KB Output is correct
15 Correct 65 ms 9996 KB Output is correct
16 Correct 43 ms 9164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 69 ms 9868 KB Output is correct
3 Correct 67 ms 9924 KB Output is correct
4 Correct 57 ms 9932 KB Output is correct
5 Correct 45 ms 8428 KB Output is correct
6 Correct 70 ms 9924 KB Output is correct
7 Correct 63 ms 10144 KB Output is correct
8 Correct 63 ms 9928 KB Output is correct
9 Correct 43 ms 9292 KB Output is correct
10 Incorrect 57 ms 9408 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 309 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 472 KB Output is correct
6 Runtime error 285 ms 524288 KB Execution killed with signal 9
7 Halted 0 ms 0 KB -