Submission #638479

# Submission time Handle Problem Language Result Execution time Memory
638479 2022-09-06T08:54:59 Z Nelt Game (APIO22_game) C++17
0 / 100
0 ms 208 KB
#include "game.h"
// #include <bits/stdc++.h>
#define S second
#define F first
#define ll long long
#define ull unsigned long long
#define ld long double
#define npos -1ULL
#define INF 2000000000000000000
#define elif else if
#define vv(a) vector<a>
#define pp(a, b) pair<a, b>
#define pq(a) priority_queue<a>
#define qq(a) queue<a>
#define ss(a) set<a>
#define mm(a, b) map<a, b>
#define pb push_back
#define sync                    \
  ios_base::sync_with_stdio(0); \
  cin.tie();                    \
  cout.tie()
#define endl "\n"
#define allc(a) begin(a), end(a)
#define all(a) a, a + (sizeof(a) / sizeof(a[0]))
#define ins insert
typedef char chr;
ll n, k, dsu[300005];
ll Repr(ll x)
{
  if (dsu[x] == x)
    return x;
  return dsu[x] = Repr(dsu[x]);
}
bool Union(ll x, ll y)
{
  x = Repr(x);
  if (dsu[y] == y and y >= k)
  {
    dsu[y] = x;
    return 1;
  }
  y = Repr(y);
  if (x == y)
    return 1;
  if (x < k)
  {
    dsu[y] = x;
    return 1;
  }
  return 0;
}
void init(int n1, int k1)
{
  n = n1, k = k1;
  for (ll i = 0; i < k; i++)
    dsu[i] = 0;
  for (ll i = k; i < n; i++)
    dsu[i] = i;
}

int add_teleporter(int u, int v)
{
  if (u == v)
    return 1;
  ll repru = Repr(u), reprv = Repr(v);
  bool add = Union(repru, reprv);
  if (add and not (Repr(u) != repru or Repr(v) != reprv) and (repru < k or reprv < k))
    return 1;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Incorrect 0 ms 208 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Incorrect 0 ms 208 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Incorrect 0 ms 208 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Incorrect 0 ms 208 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Incorrect 0 ms 208 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -