ICode9

精准搜索请尝试: 精确搜索
  • 217A - Ice Skating2022-06-19 08:00:14

    并查集: 思路:把所有x或y相同的点合并成一个集合,所需要加的点数就是连通块数量-1。 #include <iostream> using namespace std; const int N = 110; int n; int x[N],y[N],p[N]; int find (int x) { if (p[x] != x) p[x] = find (p[x]); return p[x]; } int main () { cin >> n;

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有