亲戚 并查集+人数求和 #includeusingnamespacestd;constintMAXN=100010;intfa[MAXN],size[MAXN];intn,m;charc;voidinit(){for(inti=1;i>n>>m;init();while(m--){cin>>c;if(c=='M'){inta 题解列表 2024年10月21日 1 点赞 0 评论 560 浏览 评分:9.9
亲戚 并查集+人数求和 #includeusingnamespacestd;intn,m,a,b;charc;structrelation{intfa,cnt;};relationf[100010];voidinit(){for(inti=1;i>n>>m;init();while(m--){cin>>c;if(c=='M' 题解列表 2024年10月21日 0 点赞 0 评论 461 浏览 评分:9.9
搭配购买(buy) 并查集+01背包dp问题 #includeusingnamespacestd;constintN=1e4+5;intfather[N];intvalue[N],cost[N];intdp[N];intn,m,w;intfind(intx){if(father[x]!=x){x=find(father[x]);}returnfa 题解列表 2024年10月21日 1 点赞 0 评论 523 浏览 评分:9.9
题可以贪心做,人要看准了爱. #权重=价值/重量就是先拿(价值/重量)权重最大的,最后拿不下了就分割(权重*剩下背包重量)拿走就行了```cpp#include#defineULLunsignedlonglong#defineintlonglong#defineendl'\n'#definedebug(a)coutc[i].v;c 题解列表 2024年10月21日 0 点赞 2 评论 618 浏览 评分:9.9
[金银岛]自定义排序优先'均权'最大--我看题解都太复杂辣 #贪心自定义排序找均权值最大####好久没发题解了。。。#####核心思路:通过价值/重量得到单位价值######按照单位价值从大到小得顺序装直到装不下为止#####**金属可切割######若装不下整个金属那么就能装多少装多少按照价值/重量*能装下得重量######ACCode:```cpp#inc 题解列表 2024年10月20日 0 点赞 1 评论 672 浏览 评分:9.9
优质题解 团伙(group) 并查集 #includeusingnamespacestd;intn,m;into,p,q;intfather[1001];inte[1001];intres=0;intfind(intx){if(father[x]!=x){x=find(father[x]);}returnfather[x];}voidin 题解列表 2024年10月20日 174 点赞 0 评论 8275 浏览 评分:9.9
2878: 计算矩阵边缘元素之和 摘要:解题思路:注意事项:参考代码:#include <bits/stdc++.h>using namespace std;typedef long long ll;const int N=2e3;ll a…… 题解列表 2024年10月20日 0 点赞 0 评论 2221 浏览 评分:0.0
2881: 图像相似度 摘要:解题思路:注意事项:参考代码:#include <bits/stdc++.h>using namespace std;typedef long long ll;const int N=2e3;ll a…… 题解列表 2024年10月20日 2 点赞 0 评论 635 浏览 评分:0.0
快速幂方法(需掌握) 摘要:参考代码:#include<bits/stdc++.h> using namespace std; #define int long long int fastPow(int a,int n,i…… 题解列表 2024年10月20日 1 点赞 0 评论 648 浏览 评分:0.0
1025: [编程入门]数组插入处理 解题思路:从后往前比较数组中的数值与目标数值的大小,若目标数值小于数组中的数,则数组中的数值向后移动,直到目标值大于数组中的数值,此时对应的数组中正好有一个空位,将目标值放入。然后遍历数组。注意事项:当把目标值放入时,结束循环。参考代码:#includeusingnamespace 题解列表 2024年10月20日 0 点赞 4 评论 818 浏览 评分:9.9