Submission #440626

#TimeUsernameProblemLanguageResultExecution timeMemory
440626MetalPowerKeys (IOI21_keys)C++17
9 / 100
112 ms11160 KiB
#include <bits/stdc++.h> using namespace std; #include "keys.h" struct disjoint_set{ int p[300005], sz[300005]; disjoint_set(){ for(int i = 0; i <= 300000; i++){ sz[i] = 1; p[i] = i; } } int f(int x){ if(x == p[x]) return x; else return p[x] = f(p[x]); } int ds(int x){ return sz[f(x)]; } void Join(int u, int v){ int fu = f(u), fv = f(v); if(fu == fv) return; p[fu] = fv; sz[fv] += sz[fu]; } } dsu; int node_size[300005]; vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c){ bool all_zero = true; int N = r.size(), M = u.size(); for(int j = 0; j < M; j++) dsu.Join(u[j], v[j]); int mn = 1e9; for(int i = 0; i < N; i++){ node_size[i] = (r[i] == 0 ? dsu.ds(i) : 1); mn = min(mn, node_size[i]); } vector<int> ans(N); for(int i = 0; i < N; i++) ans[i] = node_size[i] <= mn; return ans; }

Compilation message (stderr)

keys.cpp: In function 'std::vector<int> find_reachable(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
keys.cpp:36:7: warning: unused variable 'all_zero' [-Wunused-variable]
   36 |  bool all_zero = true;
      |       ^~~~~~~~
#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...