题目链接:http://codeforces.com/gym/101981/attachments There are n heroes and m monsters living in an island. The monsters became very vicious these days,so the heroes decided to diminish the monsters in the island. However, the i-th hero can only kill on…
题面 题意:n个英雄,m个怪兽,第i个英雄可以打第i个集合里的一个怪兽,一个怪兽可以在多个集合里,有k瓶药水,每个英雄最多喝一次,可以多打一只怪兽,求最多打多少只 n,m,k<=500 题解:显然的最大流裸题,多加一个药水点,药酱入度k,然后再连向英雄 队友抄的模板所以不是我的那个板子 #include<bits/stdc++.h> using namespace std; struct Edge { int from,to,cap,flow; Edge(int u,int v,int…
题面 题意:给你1个20*20的格子图,有的是障碍有的是怪,你可以每次指定上下左右的方向,然后所有怪都会向那个方向走, 如果2个怪撞上了,就融合在一起,让你给不超过5w步,让所有怪都融合 题解:我们可以选择一个边角的位置,每次都让一个怪移动到那里,同时暴力维护剩下的怪的位置,暴力走就可以了 不过后面发现好像直接随机也能过去? 下面我们队3个人的... #include <iostream> #include<string> #include<cstring> #incl…
题面 题意:给你2个串(长度1e6),在第一个串里找“s1s2s3”,第二个串里找“s4”,拼接后,是一个回文串,求方案数 题解:知道s1和s4回文,s2和s3回文,所以我们枚举s1的右端点,s1的长度乘以s2起始点为左边界的回文串的数量,累加就是答案. 所以先求s1,再求以每个点为左边界的回文串的数量 就是求每个后缀匹配第二个串的LCP(扩展kmp,或者hash+二分)二的话,后面部分用(Manacher+前缀和)就可以解决 #include<bits/stdc++.h> using nam…
题面 题意:数一个n阶三角形中,有多少个全等三角形,n<=1e9 题解:拿到题想找规律,手画开始一直数漏....,最后还是打了个表 (打表就是随便定个点为(0,0),然后(2,0),(4,0),(6,0),(1,sqrt(3)),(3,sqrt(3)),(5,sqrt(3)),(2,2*sqrt(3))...)这样 然后枚举三点算 打出来1,5,15,70,126,210,330,495,715,1001,1365,1820,2380,3060,3876 队友是插值法找的,我是纯找规律的,因为看…
题面 题意:给你100个三维空间里的点,让你求一个点,使得他到所有点距离最大的值最小,也就是让你找一个最小的球覆盖掉这n个点 题解:红书模板题,这题也因为数据小,精度也不高,所以也可以用随机算法,模拟退火之类的 #include<bits/stdc++.h> using namespace std; int npoint,nouter; struct Tpoint { double x,y,z; }; Tpoint pt[],outer[],res; #define eps 1e-9 doub…
题面 题意:1e6的数组(1<a[i]<1e6),     mul (l,r) =l × (l+1) ×...× r,  fac(l,r) 代表 mul(l,r) 中不同素因子的个数,求sigma(i=1 to n) sigma(j=i to n) fac(i,j) 题解:计数套路题,算贡献,直接算有多少区间包含某一个素数的倍数 记录一下所有2的倍数的位置,3的倍数的位置, 之后算有多少个区间包含2倍数的位置,这个就是2这个素数的倍数的贡献, 然后算有多少个区间包含3这个素数的倍数的位置,这个…
题面 题意:一堆有n个石子,编号从1⋯N排成一列,两个人Adrien 和Austin玩游戏,每次可以取1⋯K个连续编号的石子,Adrien先手,谁不能取了则输 题解:k==1时,显然和n奇偶相关,当k>1,先手的人总是可以把这n个石头分成两组相等数量的石头(从中间拿,自己控制奇偶),后手的人无论怎么操作,你都可以再 另一段中copy他的操作,这样保证了先手的人一定能有石头拿,所有先手必胜.注意特判n==0的情况 #include<bits/stdc++.h> using namespac…
题目链接:http://codeforces.com/gym/101981/attachments The use of the triangle in the New Age practices seems to be very important as it represents the unholytrinity (Satan, the Antichrist and the False Prophet bringing mankind to the New World Order with…
题目链接:http://codeforces.com/gym/101981/attachments 题意: 令 $mul(l,r) = \prod_{i=l}^{r}a_i$,且 $fac(l,r)$ 代表 $mul(l,r)$ 的不同素因子个数.求 $\sum_{i=1}^{n}\sum_{j=i}^{n}fac(i,j)$. InputThe first line contains one integer n (1 \le n \le 10^6) — the length of the se…
题目链接:http://codeforces.com/gym/101981/problem/K Your friend has made a computer video game called “Kangaroo Puzzle” and wants you to give it a try for him. As the name of this game indicates, there are some (at least 2) kangaroos stranded in a puzzle…
2019 ICPC Asia Nanjing Regional A - Hard Problem 计蒜客 - 42395 若 n = 10,可以先取:6,7,8,9,10.然后随便从1,2,3,4,5里面选一个都肯定符合题意 若 n = 9,可以先取:5,6,7,8,9,然后随便从1,2,3,4里面选一个都肯定符合题意. 所以答案就是后半部分的数量+1 #include <cstdio> #include <iostream> #include <cmath> #inc…
题目链接:https://codeforces.com/gym/102028/problem/C Lewis likes playing chess. Now he has n rooks on the chessboard with $n$ rows and $n$ columns. All rows of the chessboard are labelled with $1$ through $n$ from top to bottom. All columns of the chessb…
传送门:https://codeforces.com/gym/102082/attachments 题解: 代码: /** * ┏┓ ┏┓ * ┏┛┗━━━━━━━┛┗━━━┓ * ┃ ┃ * ┃ ━ ┃ * ┃ > < ┃ * ┃ ┃ * ┃... ⌒ ... ┃ * ┃ ┃ * ┗━┓ ┏━┛ * ┃ ┃ Code is far away from bug with the animal protecting * ┃ ┃ 神兽保佑,代码无bug * ┃ ┃ * ┃ ┃ * ┃ ┃ * ┃…
题目传送门 题号 A B C D E F G H I J K L 状态 Ο . . Ο . . Ø Ø Ø Ø . Ο Ο:当场 Ø:已补 .  :  待补 A. Edit Distance Thinking:kk pai爷 Code:kk 不能直接反转,比如"010101",直接反转后就变成"101010",右移一位,然后加个0就可以了. 所以要先统计01的数量,如果0大于1,就全变成1,1大于0,就全变成0(从数量上的改变就大于s/2了),相等的话,就看首位是0…
题目:在直角坐标系中给定 p1,p2,p3构成三角形,给定p4可能在三角形边上也可能不在, 问能不能在三角形上找出p5,使得线段p4p5,平分三角形(p4必须在三角形上).不能则输出-1. 思路:四个点,三条边,三条边的长度,和代码的数据一一对应存储. 最麻烦的就是p4只存在于一条边上. 代码: #include<bits/stdc++.h> using namespace std; ; int sgn(double x) { ; ); ; } struct Point { double x,…
Miku is matchless in the world!” As everyone knows, Nakano Miku is interested in Japanese generals, so Fuutaro always plays a kind of card game about generals with her. In this game, the players pick up cards with generals, but some generals have con…
H题意: 给你一个n个节点n-1条无向边构成的树,每一个节点有一个权值wi,你需要把这棵树划分成k个子树,每一个子树的权值是这棵子树上所有节点权值之和. 你要输出这k棵子树的权值中那个最大的.你需要让输出的结果尽可能小 题解: 二分结果,重要的是判断这个二分的值是否满足题目要求 对于划分子树的选择,就选择子树中权值最大且又满足二分的答案的那个子树 代码: #include <bits/stdc++.h> using namespace std; typedef long long ll; co…
摘要 本文主要给出了2018 ACM-ICPC Asia Beijing Regional Contest的部分题解,意即熟悉区域赛题型,保持比赛感觉. Jin Yong’s Wukong Ranking List 题意 输入关系组数n和n组关系,每组关系是s1 > s2,问第一出现矛盾的组,或者没有矛盾就输出0. 解题思路 第一感觉是拓扑排序,未完,又写了一个深搜的传递闭包,1 A,和2018年河南省赛的题很像. 代码 #include <cstdio> #include <ma…
摘要: 本文是The 2018 ACM-ICPC Asia Qingdao Regional Contest(青岛现场赛)的部分解题报告,给出了出题率较高的几道题的题解,希望熟悉区域赛的题型,进而对其他区域赛的准备有借鉴意义. Function and Function 题意 给出x和k,计算gk(x). 解题思路 通过观察发现,g函数经过一定次数的递推一定会在0和1之间变换,所以循环内加判断提前结束递推即可. 易错分析 注意计算f(0)返回的是1的问题,下面的写法避免了这种错误. 代码实现 #…
The 2018 ACM-ICPC Asia Qingdao Regional Contest 青岛总体来说只会3题 C #include<bits/stdc++.h> using namespace std; #define maxn 3000005 char a[maxn],b[maxn]; int c[maxn],ll[maxn],rr[maxn]; int main(){ int t; cin>>t; while(t--){ int n; scanf("%d&qu…
题目链接:Kattis - largesttriangle Description Given \(N\) points on a \(2\)-dimensional space, determine the area of the largest triangle that can be formed using \(3\) of those \(N\) points. If there is no triangle that can be formed, the answer is \(0\…
ACM-ICPC Asia Beijing Regional Contest 2018 Reproduction hihocoder1870~1879 A 签到,dfs 或者 floyd 都行. #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef long double LD; typedef pair<int,int> pii; typedef pair<LL,int>…
题目链接: 2018 ICPC Pacific Northwest Regional Contest - I-Inversions 题意 给出一个长度为\(n\)的序列,其中的数字介于0-k之间,为0表示这个位置是空的.现在可以在这些空的位置上任意填入1-k之间的数字(可以重复).问最多可以总共有多少对逆序对.(如果\(i<j,p_i>p_j\),则称\((i,j)\)是一对逆序对) \(1\leq n\leq 2*10^5,\ 1\leq k\leq 100\) 思路 第一步,先证明最优的填…
Magic Potion http://codeforces.com/gym/101981/attachments/download/7891/20182019-acmicpc-asia-nanjing-regional-contest-en.pdf 从源点到英雄分别拉容量为1和2的边,跑两遍网络流,判断两次的大小和k的大小 #include<iostream> #include<cstring> #include<string> #include<cmath&g…
A. Adrien and Austin 大意: $n$个石子, 编号$1$到$n$, 两人轮流操作, 每次删除$1$到$k$个编号连续的石子, 不能操作则输, 求最后胜负情况. 删除一段后变成两堆, 可以用$sg$函数打表找规律 #include <iostream> #include <cstdio> using namespace std; int main() { int n,k; cin>>n>>k; ; ) ; ?"Adrien&quo…
题意: n个英雄,m个怪兽,第i个英雄可以打第i个集合里的怪兽,一个怪兽可以在多个集合里 有k瓶药水,每个英雄最多喝一次,可以多打一只怪兽,求最多打多少只 n,m,k<=500 思路: 最大流,建图方式: 代码: #include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<cstring> #include<string> //…
题目:https://vj.69fa.cn/12703be72f729288b4cced17e2501850?v=1552995458 dp这个题目网上说是dp+离散化这个题目要对这些数字先处理然后进行dp,这个处理值得学习一下,就是把数字范围为1~1e9,转化成一个顺序列表,这个顺序列表每一个不同的位置含有不同的难度,dp[i][j]代表前面i种选出j种的方案数. #include <cstdio> #include <iostream> #include <cstdlib…
A:Zero Array 题意:两种操作, 1 p v  将第p个位置的值改成v  2  查询最少的操作数使得所有数都变为0  操作为可以从原序列中选一个非0的数使得所有非0的数减去它,并且所有数不能变为负数 思路:考虑第二种操作,显然,最少的操作数肯定是不同数的个数 用map 记录,特殊注意0的存在 #include <bits/stdc++.h> using namespace std; #define N 100010 unordered_map <int, int> mp;…
Solution A:Careful Thief 题意:给出n个区间,每个区间的每个位置的权值都是v,然后找长度为k的区间,使得这个区间的所有位置的权值加起来最大,输出最大权值, 所有区间不重叠 思路:贪心的想法,长度为k的区间的起始点肯定是某个区间的起始点,或者长度为k的区间的结束点肯定是某个区间的结束点. 因为存在最优的答案,它的起点不在某个区间的起点,那么只有两种情况. 1° 不属于任何已知区间 2° 在某个已知区间的内部 首先考虑第一种情况  如果不属于任何已知区间,那么根据贪心,我肯定…