Submission #295737

#TimeUsernameProblemLanguageResultExecution timeMemory
295737TangentWerewolf (IOI18_werewolf)C++17
15 / 100
4024 ms24236 KiB
#include <bits/stdc++.h>
#include "werewolf.h"

using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(), order_of_key()

typedef long long ll;
typedef long double dd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<dd, dd> pdd;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<dd> vdd;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;
typedef vector<vii> vvii;
typedef vector<vll> vvll;
typedef vector<vdd> vvdd;
typedef vector<vpii> vvpii;
typedef vector<vpll> vvpll;
typedef vector<vpdd> vvpdd;
typedef vector<bool> vb;

const int inf = 1 << 30;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define ffor(i, a, b) for(ll i = a; i < b; i++)
#define forin(x, a) for (auto &x: a)
#define all(x) x.begin(), x.end()

#ifdef TEST
#define dbg(x) cout << #x << ": " << x << '\n';
#define dbgc(x) cout << #x << ":"; forin(a, x) { cout << " " << a; } cout << endl;
#define tassert(x) assert(x);
#else
#define dbg(x)
#define dbgc(x)
#define tassert(x)
#endif

std::vector<int> check_validity(int N, std::vector<int> X, std::vector<int> Y,
                                std::vector<int> S, std::vector<int> E,
                                std::vector<int> L, std::vector<int> R) {
  int Q = S.size();
  int M = X.size();
  vvii adj(N);
  rep(i, M) {
    adj[X[i]].emplace_back(Y[i]);
    adj[Y[i]].emplace_back(X[i]);
  }
  vii res;
  rep(i, Q) {
    vb vis(N);
    deque<int> q1, q2;
    q1.emplace_back(S[i]);
    while (!q1.empty()) {
      int u = q1.front();
      q1.pop_front();
      if (vis[u]) {
        continue;
      }
      vis[u] = true;
      if (u <= R[i]) {
        q2.emplace_back(u);
      }
      forin(v, adj[u]) {
        if (!vis[v] && v >= L[i]) {
          q1.emplace_back(v);
        }
      }
    }
    vis.assign(N, false);
    while (!q2.empty() && !vis[E[i]]) {
      int u = q2.front();
      q2.pop_front();
      if (vis[u]) {
        continue;
      }
      vis[u] = true;
      forin(v, adj[u]) {
        if (!vis[v] && v <= R[i]) {
          q2.emplace_back(v);
        }
      }
    }
    res.emplace_back(vis[E[i]]);
  }

  return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...