제출 #403474

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
4034742021-05-13 08:26:49shenxy족보 (KOI18_family)C++11
59 / 100
47 ms34884 KiB
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int, int> ii;
struct UFDS {
vector<int> parent, size;
UFDS(int N) {
for (int i = 0; i < N; ++i) parent.push_back(i), size.push_back(1);
}
int find_parent(int i) {
if (parent[i] == i) return i;
return parent[i] = find_parent(parent[i]);
}
int get_size(int i) {
return size[find_parent(i)];
}
void union_set(int u, int v) {
u = find_parent(u), v = find_parent(v);
if (u == v) return;
if (size[u] < size[v]) parent[u] = v, size[v] += size[u];
else parent[v] = u, size[u] += size[v];
}
};
vector<int> children[10000], leaf[10000];
void dfs(int v) {
for (int i: children[v]) {
dfs(i);
for (int j: leaf[i]) leaf[v].push_back(j);
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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

family.cpp: In function 'int main()':
family.cpp:58:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |   for (int i = 1; i < leaf[x].size(); ++i) sets.union_set(leaf[x][i - 1], leaf[x][i]);
      |                   ~~^~~~~~~~~~~~~~~~
family.cpp:59:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |   if (sets.get_size(leaf[x][0]) != leaf[x].size()) {
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
family.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |  scanf("%d %d %d", &N1, &N2, &K);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
family.cpp:37:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |   scanf("%d", &p);
      |   ~~~~~^~~~~~~~~~
family.cpp:42:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |   scanf("%d", &p);
      |   ~~~~~^~~~~~~~~~
family.cpp:46:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |   scanf("%d", &p);
      |   ~~~~~^~~~~~~~~~
family.cpp:51:5: warning: 'r2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   51 |  dfs(r2);
      |  ~~~^~~~
family.cpp:50:5: warning: 'r1' may be used uninitialized in this function [-Wmaybe-uninitialized]
   50 |  dfs(r1);
      |  ~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...