제출 #1058697

#제출 시각아이디문제언어결과실행 시간메모리
1058697qwusha열쇠 (IOI21_keys)C++17
9 / 100
152 ms40428 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define fi first #define se second typedef long double ld; const ld eps = 1e-8; mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count()); const ll inf = 1e18; const ll mod = 1e9 + 7; #include "keys.h" vector<set<int>> g; vector<int> num; int cnt = 0; void dfs(int v, int number) { num[v] = number; cnt++; for (auto u : g[v]) { if (num[u] == -1) { dfs(u, number); } } } vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) { ll n = r.size(); int m = u.size(); vector<int> res(n); bool nonzer = 0; for (int i = 0; i < n; i++) { if (r[i] != 0) nonzer = 1; } g.resize(n); for (int i = 0; i < m; i++) { g[u[i]].insert(v[i]); g[v[i]].insert(u[i]); } num.resize(n, -1); vector<int> sz; int mini = n + 1; for (int i = 0; i < n; i++) { if (num[i] == -1) { cnt = 0; dfs(i, sz.size()); sz.push_back(cnt); mini = min(mini, cnt); } } for (int i = 0; i < n; i++) { if (nonzer) { if (r[i] != 0 || sz[num[i]] == 1) { res[i] = 1; } } else { if (sz[num[i]] == mini) { res[i] = 1; } } } 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...
#Verdict Execution timeMemoryGrader output
Fetching results...