Acwing - 每日一题 - 重新排列奶牛
题目
思路
其实可以看成 n 个点炼成一个环 5 -> 1 -> 2 -> 5,有多少个连通块,然后最长的连通块的个数,连接每个点可以用并查集来实现
AC code
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 110;
int n;
int a[N], b[N];
int p[N];// 存储每个点的
原创
2022-04-25 21:48:45 ·
114 阅读 ·
1 评论