摘要: 题意: n 道题,2 个答题者,已知二者的做题情况,你是受贿裁判,可以给每题指定分值(≥1),求甲乙分数(甲>乙)相差最小时最大分值的最小值。 思路: 统计只有甲或乙做出的题目数。 加一取下整判同余: #include <bits/stdc++.h> using namespace std; int 阅读全文
posted @ 2020-03-18 20:17 Kanoon 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 数据有些弱,Union函数不判不等也可以过。 题意: 依次给出 n 个人的兴趣,不同人兴趣相交、不同兴趣所属人员相交均属于同一集群,求形成的不相交集群个数及每个集群的人数。 思路: 枚举每个兴趣的人员,以序号最小者作为集群代表与其他成员合并,追加 cnt 数组记录每个集群的人数。 如题目输入: 1 阅读全文
posted @ 2020-03-17 14:12 Kanoon 阅读(173) 评论(0) 推荐(0) 编辑
摘要: N ≤ 104,输入如下数据如果没有路径压缩可能会超时。 10000 2 1 2 2 3 4 2 5 6 …… 2 9997 9998 2 9999 10000 2 9999 9997 …… 2 5 3 2 3 1 10000 10000 10000 …… 10000 10000 但事实上,两种写法 阅读全文
posted @ 2020-03-17 12:32 Kanoon 阅读(157) 评论(0) 推荐(0) 编辑
摘要: Tips: 数据范围较小时可把二维数组当做map<pair<int,int>,int>使用。 #include <bits/stdc++.h> using namespace std; const int M=110; int fri[M]; bool is_enemy[M][M]; int Fin 阅读全文
posted @ 2020-03-17 10:52 Kanoon 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 题意: 给定每个人的家庭成员和其自己名下的房产,请你统计出每个家庭的人口数、人均房产面积及房产套数。 思路: 输入和输出各构造一个结构体,利用并查集归并输入,枚举编号进行输出。 #include <bits/stdc++.h> using namespace std; const int M=110 阅读全文
posted @ 2020-03-16 22:30 Kanoon 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 题意: n x m 的网格,p 个玩家轮流BFS,给出每个玩家每次能遍历的最远距离和网格初始状态(可遍历点、障碍点、每个玩家的遍历起点(可多个)),问每个玩家最多能遍历多少点。 Tips: 以所有玩家无法再进行遍历而不是已遍历所有点为终止条件。 #include <bits/stdc++.h> us 阅读全文
posted @ 2020-03-16 17:50 Kanoon 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 题意: 长为 n,由 l ~ r 中的数组成,其和模 3 为 0 的数组数目。 思路: dp[ i ][ j ] 为长为 i,模 3 为 j 的数组数目。 #include <bits/stdc++.h> using namespace std; const int M=220000; const 阅读全文
posted @ 2020-03-16 17:32 Kanoon 阅读(111) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> using namespace std; int main() { int n,k;cin>>n>>k; string s;cin>>s; int ans[26]={0}; for(int i=0;i<n;i++){ int len=1; while 阅读全文
posted @ 2020-03-16 17:21 Kanoon 阅读(89) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> using namespace std; int main() { int n;cin>>n; int a[n];for(int &i:a) cin>>i; int ans_ave=0,ans_cost=INT_MAX; for(int i=1;i< 阅读全文
posted @ 2020-03-16 17:16 Kanoon 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 题意: 寻找异或后值为 u,相加后和为 v 的最短数组。 思路: 异或得 u ,则 v 至少应大于等于 u ,且多出来的部分可以等分为两份相消。 即初始数组为 u , (v-u)/2 , (v-u)/2,之后即为特判或判断是否可以合并。 #include <bits/stdc++.h> using 阅读全文
posted @ 2020-03-15 02:05 Kanoon 阅读(258) 评论(0) 推荐(1) 编辑