Submission #758838

#TimeUsernameProblemLanguageResultExecution timeMemory
758838fanwenKeys (IOI21_keys)C++17
9 / 100
3059 ms26140 KiB
/** * author : pham van sam * created : 15 June 2023 (Thursday) **/ #define ONLINE_JUDGE #include <bits/stdc++.h> using namespace std; using namespace chrono; #define MASK(x) (1LL << (x)) #define BIT(x, i) (((x) >> (i)) & 1) #define ALL(x) (x).begin(), (x).end() #define REP(i, n) for (int i = 0, _n = n; i < _n; ++i) #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i) #define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; --i) #define FORE(it, s) for (__typeof(s.begin()) it = (s).begin(); it != (s).end(); ++it) template <typename U, typename V> bool maximize(U &A, const V &B) { return (A < B) ? (A = B, true) : false; } template <typename U, typename V> bool minimize(U &A, const V &B) { return (A > B) ? (A = B, true) : false; } vector <int> find_reachable (vector <int> type_keys, vector <int> u, vector <int> v, vector <int> c) { int N = (int) type_keys.size(); int M = (int) u.size(); vector <int> dd(N), p(N, 1), ans(N); vector <vector <int>> adj(N); REP(i, M) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } int run = 0; function <void(int)> dfs = [&] (int u) { if(dd[u]) return ; dd[u] = 1; run++; for (auto v : adj[u]) dfs(v); }; REP(u, N) if(!type_keys[u]) { fill(ALL(dd), 0); run = 0; dfs(u); p[u] = run; } int cur = *min_element(ALL(p)); REP(i, N) ans[i] = (cur == p[i]); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...