제출 #796161

#제출 시각아이디문제언어결과실행 시간메모리
796161t6twotwo열쇠 (IOI21_keys)C++17
9 / 100
73 ms10128 KiB
#include "keys.h" #include <bits/stdc++.h> using namespace std; using ll = long long; struct dsu { int n; vector<int> p, s; dsu(int n) : n(n), p(n), s(n, 1) { iota(p.begin(), p.end(), 0); } int find(int x) { return x == p[x] ? x : p[x] = find(p[x]); } int size(int x) { return s[find(x)]; } bool same(int x, int y) { return find(x) == find(y); } bool unite(int x, int y) { x = find(x); y = find(y); if (x == y) { return 0; } if (s[x] > s[y]) { swap(x, y); } p[x] = y; s[y] += s[x]; return 1; } }; vector<int> find_reachable(vector<int> R, vector<int> U, vector<int> V, vector<int> C) { int N = R.size(), M = C.size(); if (C == vector(M, 0)) { dsu uf(N); for (int i = 0; i < M; i++) { uf.unite(U[i], V[i]); } vector<int> p(N); for (int i = 0; i < N; i++) { if (R[i] == 0) { p[i] = uf.size(i); } else { p[i] = 1; } } int mn = *min_element(p.begin(), p.end()); vector<int> ans(N); for (int i = 0; i < N; i++) { if (p[i] == mn) { ans[i] = 1; } } return ans; } }

컴파일 시 표준 에러 (stderr) 메시지

keys.cpp: In function 'std::vector<int> find_reachable(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
keys.cpp:58:1: warning: control reaches end of non-void function [-Wreturn-type]
   58 | }
      | ^
#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...