题目链接:点击打开链接 题意:给你n个数, 问最长的题目中定义的斐波那契数列.  思路:枚举開始的两个数, 由于最多找90次, 所以能够直接暴力, 用map去重.  注意, 该题卡的时间有点厉害啊. 用了两个map结果超时. 细节參见代码: #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<string> #include<v…
D. Fibonacci-ish 题目连接: http://www.codeforces.com/contest/633/problem/D Description Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if the sequence consists of at least two elements…
H. Fibonacci-ish II 题目连接: http://codeforces.com/contest/633/problem/H Description Yash is finally tired of computing the length of the longest Fibonacci-ish sequence. He now plays around with more complex things such as Fibonacci-ish potentials. Fibo…
D. Fibonacci-ish time limit per test 3 seconds memory limit per test 512 megabytes input standard input output standard output Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if th…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Dante is engaged in a fight with "The Savior". Before he can fight it with his sword, he needs to break its shields. He has two guns, E…
暴力 A - Ebony and Ivory import java.util.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner cin = new Scanner (new BufferedInputStream (System.in)); int a = cin.nextInt (); int b = cin.nextInt (); int c = cin.nex…
A. Ebony and Ivory 题目连接: http://www.codeforces.com/contest/633/problem/A Description Dante is engaged in a fight with "The Savior". Before he can fight it with his sword, he needs to break its shields. He has two guns, Ebony and Ivory, each of t…
B. A Trivial Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mr. Santa asks all the great programmers of the world to solve a trivial problem. He gives them an integer m and asks f…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output After observing the results of Spy Syndrome, Yash realised the errors of his ways. He now believes that a super spy such as Siddhant can't u…
题目链接:http://codeforces.com/problemset/problem/633/G 大意是一棵树两种操作,第一种是某一节点子树所有值+v,第二种问子树中节点模m出现了多少种m以内的质数. 第一种操作非常熟悉了,把每个节点dfs过程中的pre和post做出来,对序列做线段树.维护取模也不是问题.第二种操作,可以利用bitset记录质数出现情况.所以整个线段树需要维护bitset的信息. 对于某一个bitset x,如果子树所有值需要加y,则x=(x<<y)|(x>>…
题目链接:http://codeforces.com/problemset/problem/633/C 大意就是给个字典和一个字符串,求一个用字典中的单词恰好构成字符串的匹配. 比赛的时候是用AC自动机写的,就是对于trie中每一个节点,判断是否为终结点,以及当前字符所在位置p减去trie中这个节点的深度也即某一单词的长度l,判断dp[p-l]是否可以被构成,可以的话直接break并且标记当前dp值. 赛后想了想,其实直接一个trie就行了,每个单词才1000的长度,又想起来我去年给人讲过类似的…
数学技巧真有趣,看出规律就很简单了 wa 题意:给出数k  输出所有阶乘尾数有k个0的数 这题来来回回看了两三遍, 想的方法总觉得会T 后来想想  阶乘 emmm  1*2*3*4*5*6*7*8*9*10...*n 尾数的0只与5有关 是5的几倍就有几个0  因为5前面肯定有偶数 乘起来就有一个0 而且最后输出肯定是连续的5个 hhh 兴奋 开始上手 乱搞一下  发现复杂度还行 测样例 发现 k=5 的时候不对了 输出25~29了 应该是0的 咦  测了一下 25!应该是6个0的 25=5*5…
E. Startup Funding 题目连接: http://codeforces.com/contest/633/problem/E Description An e-commerce startup pitches to the investors to get funding. They have been functional for n weeks now and also have a website! For each week they know the number of u…
G. Yash And Trees 题目连接: http://www.codeforces.com/contest/633/problem/G Description Yash loves playing with trees and gets especially excited when they have something to do with prime numbers. On his 20th birthday he was granted with a rooted tree of…
C. Spy Syndrome 2 题目连接: http://www.codeforces.com/contest/633/problem/C Description After observing the results of Spy Syndrome, Yash realised the errors of his ways. He now believes that a super spy such as Siddhant can't use a cipher as basic and a…
B. A Trivial Problem 题目连接: http://www.codeforces.com/contest/633/problem/B Description Mr. Santa asks all the great programmers of the world to solve a trivial problem. He gives them an integer m and asks for the number of positive integers n, such t…
B. A Trivial Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mr. Santa asks all the great programmers of the world to solve a trivial problem. He gives them an integer m and asks f…
建trie树,刚好字符串是反向的,直接在原图上向前搜索就OK了……………… 可怜的我竟然用了RK来hash,在test67那里T了…… 贴个RK的 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <set> #include <vector> #define LL…
寻找树上最大权值和的两条不相交的路径. 树形DP题.挺难的,对于我…… 定义三个变量ma[MAXN], t[MAXN], sum[MAXN] 其中,ma[i]代表i子树中,最长的路径和 t[i]代表i子树中,用来维护已有一条路径,而且还有一条链从叶子节点到i,则可以从根节点i向上扩展.如下图,维护红色部分 sum[i]维护从某叶子节点到根节点i的最长路径. 转移方程可以看代码,很容易明白 #include <iostream> #include <cstdio> #include…
Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)-C. Magic Grid-构造 [Problem Description] ​ 给你一个\(n\),构造一个\(n\times n\)的矩阵,使其满足任意一行,或一列的异或值相同.保证\(n\)能被\(4\)整除. [Solution] ​ 可以发现,从\(0\)开始,每\(4\)个连续数的异或值为\(0\),所以可以很容易使得每一行的异或值等于\(0\). ​ 列…
Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)-D. Restore Permutation-构造+树状数组 [Problem Description] ​ 给你一个长度为\(n\)的数组,第\(i\)个元素\(s_i\)表示一个排列中第\(i\)个元素之前,并且小于\(p_i\)的元素的和.求出满足此条件的排列. [Solution] ​ 假设\(n=5\),\(s[]=\{0,0,3,7,3\}\).从后往前看…
Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)-E. Let Them Slide-思维+数据结构 [Problem Description] ​ \(n\times w\)的方格中,每一行有\(cnt_i\)个数字,每一行的数字都连续的放在一起,但是可以任意的平移.问每一列的最大和为多少. [Solution] ​ 最直观的想法是对于每一列\(j\),计算出每一行中的一个区间最大值,此区间长度为\(len=w-c…
传送门 A. XORinacci 签到. Code /* * Author: heyuhhh * Created Time: 2020/2/26 9:26:33 */ #include <iostream> #include <algorithm> #include <cstring> #include <vector> #include <cmath> #include <set> #include <map> #inc…
这套题还是有点质量的吧 -- 题目链接 A. XORinacci 傻叉签到题,因为异或的性质所以这个序列的循环节长度只有 \(3\) -- 查看代码 B. Uniqueness 因为序列长度乃至数的种类都不超过 \(2000\),考虑先把序列离散化. 题意让我们求一个最短的区间满足如下性质,对于每一种数,其在此区间出现次数不小于在原序列中的出现次数减 \(1\). 可以先前缀和求一下对于每种数,当前位置及之前的出现次数,和至少一共需要删掉多少个这种数,即在原序列中的出现次数减 \(1\),方便以…
C - Equalize #include<bits/stdc++.h> using namespace std; using namespace std; string a,b; int main(){ int n; cin>>n; cin>>a>>b; ,sum=; ;j<n;j++){ if(a[j]!=b[j]) ans++; } ;j<n-;j++){ if(a[j]==b[j]) continue; ]==]=='){ sum++;…
题目链接:1037E - Trips 题目大意:有n个人,m天,每天晚上都会有一次聚会,一个人会参加一场聚会当且仅当聚会里有至少k个人是他的朋友.每天早上都会有一对人成为好朋友,问每天晚上最多能有多少人参加聚会.朋友关系不满足传递性. 相当于有n个点,进行m次加边操作,每次操作后附加一个询问,问最大点集的大小,使得点集中每个点的度数均大于等于k 题解:如果直接边加边询问可能比较麻烦,本着“正难则反”的原则,我们可以将题目转化为,初始有m条边,每次操作是先询问当前的答案,再删去一条边. 现在我们就…
题目链接:1037F - Maximum Reduction 题目大意:给出一段代码,给你一个长度为n的数组和数字k,求程序运行结果,mod 1e9+7输出 简单翻译下代码的意思,初始定义一个空数组b,分别查询区间[1,k];[2,k+1];...;[n-k+1,n]的最大值,并将这 n-k+1 个区间最大值放入b,将b中元素之和加入到ans里,并把这个长度为n-k+1的数组b放入到下一层的递归,这样就要再求n-2k+1次.n-3k+1次最大值,直到数组的长度小于k(即无法求区间长度为k的最大值…
还是dfs? 好像自己写的有锅 过不去 看了题解修改了才过qwq #include <cstdio> #include <algorithm> #include <cstring> #include <stack> #include <set> using namespace std; ],v[],n,m,k,ans; ],vis[]; ]; stack<int> S; void dfs(int u){ if(sons[u].size…
随便模拟下就过了qwq 然后忘了特判WA了QwQ #include <cstdio> #include <algorithm> #include <cstring> #include <set> #include <queue> using namespace std; ],v[],fir[],nxt[],cnt=,dep[],squ[]; ]; void addedge(int ui,int vi){ cnt++; u[cnt]=ui; v[c…
是一道水题 虽然看起来像是DP,但其实是贪心 扫一遍就A了 QwQ #include <cstdio> #include <algorithm> #include <cstring> #include <set> #include <map> using namespace std; ],b[],f[]; ],bx[]; int main(){ scanf("%d",&n); scanf(); scanf(); ;i&…