이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = a; i >= b; i--)
#define fe(x, y) for (auto& x : y)
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define pw(x) (1LL << (x))
#define sz(x) (int)x.size()
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define fbo find_by_order
#define ook order_of_key
template <typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ve = vector <T>;
template <typename T>
bool umx (T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T>
bool umn (T& a, T b) { return a > b ? a = b, 1 : 0; }
using ll = long long;
using ld = long double;
using pll = pair <ll, ll>;
using pii = pair <int, int>;
using ull = unsigned long long;
const int oo = 1e9;
const ll OO = 1e18;
const int N = 3e5 + 10;
const int M = 5e3 + 100;
const int mod = 1e9 + 7;
const bool TEST = 0;
ve <pii> G[N];
ve <pii> NG[N];
vector<int> find_reachable(vector <int> r, vector <int> u, vector <int> v, vector <int> c) {
int n = sz(r);
vector<int> ans(n, 1);
ve <int> C(n, 0);
for (int i = 0; i < sz(u); i++) {
G[u[i]].pb({v[i], c[i]});
G[v[i]].pb({u[i], c[i]});
}
for (int i = 0; i < n; i++) {
set <pii> E;
ve <bool> vis(n, 0);
ve <bool> have(n, 0);
queue <int> q;
q.push(i);
while (sz(q)) {
C[i]++;
int u = q.front();
q.pop();
have[r[u]] = 1;
for (auto [to, clr] : G[u]) if (!vis[to]) {
if (have[clr]) {
vis[to] = 1;
q.push(to);
} else {
E.insert({clr, to});
}
}
while (1) {
auto it = E.lower_bound(make_pair(r[u], -1));
if (it != E.end() && (*it).fi == r[u]) {
if (!vis[(*it).se]) {
vis[(*it).se] = 1;
q.push((*it).se);
}
E.erase(it);
} else {
break;
}
}
}
}
int mn = *min_element(all(C));
for (int i = 0; i < n; i++) {
if(C[i] == mn) ans[i] = 1;
else ans[i] = 0;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |