C. Common Subsequence 题意:给出长度为n两个串,求两个串的最长公共子序列len,如果len>=0.99*n,两个串就是亲兄弟否则不是. 解法:朴素的求LCS的时间复杂度是O(nm),这题肯定超时.正解不容易想,要注意到0.99这个特点,我们从这个特点下手也就是说最多只能抛弃0.01*n=1000个字符, 那么我们设dp[i][j]为A串前i+dp[i][j]个字符抛弃掉i个字符,B串前j+dp[i][j]个字符抛弃掉j个字符获得的LCS长度为dp[i][j]. 那么对于此时…
2020 ICPC Universidad Nacional de Colombia Programming Contest A. Approach 三分 显然答案可以三分,注意\(eps\)还有两条线平行的情况 view code #include<bits/stdc++.h> using namespace std; #pragma GCC optimize("O2") double dis2(double ox, double oy, double ex, doubl…
Tamref love random numbers, but he hates recurrent relations, Tamref thinks that mainstream random generators like the linear congruent generator suck. That's why he decided to invent his own random generator. As any reasonable competitive programmer…
Problem J Joking with Fermat's Last Theorem Fermat's Last Theorem: no three positive integers a, b, and c can satisfy the equation an + bn = cn for any integer value of n greater than two. From the theorem, we know that a3 + b3 = c3 has no positive i…
D. Wildest Dreams 这道题的意思是Ayna和Arup两人会同时在车上一段时间,在Ayna在的时候,必须单曲循环Ayna喜欢的歌,偶数段Ayna下车,若此时已经放了她喜欢的那首歌,就要将它放完,然后按照顺序播放其他的歌,输出一共播放了Ayna喜欢的歌多少分钟. 分情况考虑,加起来总和就是一共播放的时间. 做题思路: 一:奇数段的时间总和: 二:判断奇数段的时间Ayna喜欢的歌是否恰好播放完: (1)若恰好播放完,对其后的偶数段不做处理 (2)若否,判断偶数段时间是否大于此歌未播放部…
传送门 A. Enju With math problem 题意: 给出\(a_1,\cdots,a_{100}\),满足\(a_i\leq 1.5*10^8\). 现在问是否存在一个\(pos\),满足: \[ \forall x\in [1,100],a_x=\varphi(x+pos-1) \] 思路: 假设素数间隔没有超过\(100\),那就很简单,直接枚举\(a_i\),判断\(a_i+1\)是否为素数,反解出\(pos\)再来逐一验证即可. 但是素数间隔很可能是超过\(100\)的.…
题:https://nanti.jisuanke.com/t/41350 分析:先将字符串转置过来 状态转移,因为只有5个状态,所以 i 状态到 j 状态的最小代价就枚举[i][k]->[k][j]的最小值(0<=k<=4) 0:初始状态 1:2 2:20 3:201 4:2019 mat[i][j]表示状态i转移到j的最小代价 #include<bits/stdc++.h> using namespace std; #define lson root<<1,l,…
题目链接:https://nanti.jisuanke.com/t/41352 题目意思还是好理解的,看过的人不多,感觉是被通过量吓到了.其实就是个水题,反向模拟就好了, 用队列模拟,反向模拟,它要放m张卡到后面,那我就放m张卡到前面,一开始队列只有1张卡,慢慢加到n张卡, 先加大的卡,再一直到1的卡.对了,可能会出现只有5张卡,m却是6,7,8或9,10,那么为了减少不必要的模拟, 用mod来减少,因为有些模拟会让卡和之前比较,算是原封不动. #include <iostream> #inc…
题目链接:https://nanti.jisuanke.com/t/41349 题意:有一个灭火英雄,和一个灭火团队,一个人与一个团队比较. 灭火英雄到其他灭火点的最短路最大值,与一个团队到其他灭火点的最短路的最大距离*C,进行比较. 如果一个团队的一个人在k点,那么k点的最短路就是0,这样,我们可以构建一个虚拟点“0”点,跑团队的最短路 可以让“0”点到其他团队队员点为0,到其他点为inf,然后跑一次最短路就可以了,下面的代码是比赛时候的,懒得改,直接很难看的写了. #include <ios…
The Nth Item 思路: 先用特征根法求出通向公式,然后通向公式中出现了\(\sqrt{17}\),这个可以用二次剩余求出来,然后可以O(\(log(n)\))求出. 但是还不够,我们先对\(n\)欧拉降幂,然后求base为\(\sqrt{1e9}\)的快速幂,预处理一些东西,就可以类似O(1)求出了. 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include<bits/std…
链接: https://codeforces.com/gym/102394/problem/J 题意: The great mathematician DreamGrid proposes a conjecture, which states that: Every positive integer can be expressed as the sum of a prime number and a composite number. DreamGrid can't justify his c…
题意:https://nanti.jisuanke.com/t/41355 给出N1,计算公式:A=F(N)Ni=Ni-1 ^ (A*A),F为类斐波那契需要矩阵快速幂的递推式. 求第k个N. 思路: 发现从大约1e5个数开始N交替出现,到一定位置%2即可.(or正解:https://blog.csdn.net/qq_41848675/article/details/100667808   or https://blog.csdn.net/jk_chen_acmer/article/detail…
直接模拟orhttps://blog.csdn.net/liufengwei1/article/details/100643831…
B. Fire-Fighting Hero 题意:一个消防员和多个队伍比赛,比较所有地方的最短路的最大值,消防员最后的值要乘1/C,求胜利的一方的最短路的最大值是多少.一直没读懂正确题意(内疚). 思路:图论题-单源最短路径:添加一个顶点,连接各个救火团队所在的救火点,路径长度均设为 0,设该顶点为源,即变成了单源最短路径问题.使用两次Dijkstra算法可求出两个最短路径 的最大值.比较时将救火团队的乘以T进行比较可避免分数操作.(题解) AC代码: #include<bits/stdc++.…
This is an era of team success, but also an era of heroes. Throughout the ages, there have been numerous examples of using the few to defeat the many. There are VV (Numbers 11 to VV) fire-fighting points in ACM city. These fire-fighting points have E…
题意:要找到一个字符串里面存在子序列9102 而不存在8102 输出最小修改次数 思路:对于单次询问 我们可以直接区间dpOn求出最小修改次数 但是对于多次询问 我在大部分题解看到的解释一般是用线段树维护每一个区间段 每一个区间上挂一个dp[5][5]的矩阵 表示从i状态转移到j状态索要的最小修改次数 转移的时候就可以像区间dp一样 通过两个子区间合并 跟新答案. #include <bits/stdc++.h> using namespace std; const double pi = a…
2019 ICPC 南昌网络赛 比赛时间:2019.9.8 比赛链接:The 2019 Asia Nanchang First Round Online Programming Contest 总结 // 史上排名最高一次,开场不到两小时队友各A一题加水题共四题,排名瞬间升至三四十名 // 然后后三小时就自闭了,一题都没有突破...最后排名211 hhhh     B. Fire-Fighting Hero 题意 队友做的,待补.   AC代码 #include<cstdio> #includ…
AtCoder diverta 2019 Programming Contest 2 看起来我也不知道是一个啥比赛. 然后就写写题解QWQ. A - Ball Distribution 有\(n\)个气球\(k\)个人,每个人至少要拿一个气球.问所有分配方案中拿走气球最多的那个人可以比最少的那个人多拿多少个. 打比赛的时候一开始没看到题,别人说输出\(n\% k\)就过了,然后我就过了. 现在重新一看题解... 应该是\(k=1\)时,答案是\(0\),否则答案是\(n-k\). #includ…
diverta 2019 Programming Contest 2 A - Ball Distribution 特判一下一个人的,否则是\(N - (K - 1) - 1\) #include <bits/stdc++.h> #define fi first #define se second #define pii pair<int,int> #define mp make_pair #define pb push_back #define space putchar(' ')…
diverta 2019 Programming Contest 因为评测机的缘故--它unrated了.. A - Consecutive Integers #include <bits/stdc++.h> #define fi first #define se second #define pii pair<int,int> #define mp make_pair #define pb push_back #define space putchar(' ') #define…
[AtCoder] NIKKEI Programming Contest 2019   本来看见这一场的排名的画风比较正常就来补一下题,但是完全没有发现后两题的AC人数远少于我补的上一份AtCoder. A - Subscribers   首先始终 \(max = \min(A, B)\) ,\(min\) 的话如果 \(A + B \leq N\) ,那么就是 \(0\) ,否则就是 \(A + B - N\) . int n, a, b; int main() { read(n), read…
[AtCoder] Yahoo Programming Contest 2019   很遗憾错过了一场 AtCoder .听说这场是涨分场呢,于是特意来补一下题. A - Anti-Adjacency   显然 \(K \leq \frac{N + 1}2\) int n, k; int main() { #ifdef hzhkk freopen("hkk.in", "r", stdin); #endif read(n), read(k); if (k <=…
Tree Ming and Hong are playing a simple game called nim game. They have nn piles of stones numbered 11 to nn ,the ii-th pile of stones has a_iai​ stones. There are n - 1n−1 bidirectional roads in total. For any two piles, there is a unique path from…
A - Airport Coffee 留坑. B - Best Relay Team 枚举首棒 #include <bits/stdc++.h> using namespace std; #define N 510 #define INF 0x3f3f3f3f struct node { string name; double v1, v2; inline void scan() { cin >> name >> v1 >> v2; } inline boo…
比赛链接:传送门 本场我们队过的题感觉算法都挺简单的,不知道为啥做的时候感觉没有很顺利. 封榜后7题,罚时1015.第一次模拟赛金,虽然是北欧的区域赛,但还是有点开心的. Problem B Best Relay Team 00:49 (+2) Solved by xk 排序后简单模拟一下题意即可. xk说他要背个锅. 代码: #include <iostream> #include <cmath> #include <map> #include <algorit…
$$2017-2018\ ACM-ICPC\ Latin\ American\ Regional\ Programming\ Contest$$ \(A.Arranging\ tiles\) \(B.Buggy\ ICPC\) 分元音位置情况和数量讨论,没有元音答案是1,如果有元音但不在第一个位置上是无法构造出来的,然后其他情况找到最初始的情况的辅音数量即可 //#pragma comment(linker, "/STACK:1024000000,1024000000") #inclu…
\(2019-2020\ ACM-ICPC\ Brazil\ Subregional\ Programming\ Contest\) \(A.Artwork\) 并查集,把检测区域能在一起的检测器放在一个并查集里,然后判断是否有一个集合能够封住左边和上边的其中一个还有右边和下边的其中一个即可 //#pragma comment(linker, "/STACK:1024000000,1024000000") #include<bits/stdc++.h> using name…
    Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and made an amazing discovery: there are only 16 types of programming contest problems! Furthermore, the top several comprise almost 80% of the problems s…
偏方记录背包里的物品.....每个背包的价值+0.01 Happy Programming Contest Time Limit: 2 Seconds      Memory Limit: 65536 KB In Zhejiang University Programming Contest, a team is called "couple team" if it consists of only two students loving each other. In the cont…
Happy Programming Contest  ZOJ3703 老实说:题目意思没看懂...(希望路过的大神指点) 最后那个the total penalty time是什么意思啊!!! 还是学到点东西的... 解题的关键在于:要控制最后所用的时间最少,所以在程序的最开始应该先将输入的各种题目 以时间升序排列, 然后就可以保证每次都以时间小的优先选, 这样就可以保证最后相同的吸引值和解题数的情况下所花的时间最少. #include <iostream> #include <stdi…