codeforces#505--A Doggo Recoloring】的更多相关文章

A. Doggo Recoloring time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Panic is rising in the committee for doggo standardization - the puppies of the new brood have been born multi-colored! I…
[链接] 我是链接,点我呀:) [题意] 你可以把出现次数大于1的颜色换成其他颜色. 问你最后能不能全都变成同一种颜色 [题解] 判断一下有没有出现次数大于1的就好. 有的话.显然可以一直用它变颜色. 特判n=1的情况.就好. [代码] #include <bits/stdc++.h> #define LL long long #define rep1(i,a,b) for (int i = a;i <= b;i++) #define rep2(i,a,b) for (int i = a…
题意:给出一个字符串,可以向该字符串的任意位置插入一个字母使其变成回文串 因为字符串的长度小于10,枚举插入的字母,和要插入的位置,再判断是否已经满足回文串 #include<iostream> #include<cstdio> #include<cstring> #include <cmath> #include<stack> #include<vector> #include<map> #include<set&…
题意:给你一个升序的数组,元素之间如果gcd不为1可以建边,让你判断是否可以建成一颗二叉搜索树. 解法:dp,首先建图,然后进行状态转移.因为如果点k左端与i相连,右端与k相连,则i和k可以相连,同时像左右两端拓展. 最后判断1和n是否相连即可. #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> #include<vector> using namespa…
题意:给你一段字符串,可以选择任意多的位置,每个位置会反转两边的字符串,问交错的字符串最长是多长? 思路:找规律,仔细分析样例1.假设位置为 1 2 3 4 5 6 7 8 9,反转之后会发现答案是7 8 9 1 2 3 4 5 6 ,其中答案串是7 8 9 1 2,所以可以把原字符串复制一份粘在原字符串后面,找最长的交错串即可. #include<cstdio> #include<algorithm> #include<cstring> #include<ios…
题意:给你若干个数对,每个数对中可以选择一个个元素,问是否存在一种选择,使得这些数的GCD大于1? 思路:可以把每个数对的元素乘起来,然后求gcd,这样可以直接把所有元素中可能的GCD求出来,从小到大枚举即可,需要特判一下第一个元素是素数的情况. #include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #include<map> #include<s…
题意:给定一个长度为 n 的小写字母串.可以将出现次数大于等于2的字母全部变成另一个小写字母,问最后能否将该小写字母串的所有字母变成同一个字母 n<=1e5 思路: #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<iostream> #include<algorithm> #include<map> #inclu…
Codeforces Round #505 A. Doggo Recoloring 题目描述:给定一个字符串,每次选择一个在字符串里面出现至少两次的字符,然后将这种字符变成那一种指定的字符,问最终这个字符串能否只剩一种字符. solution 当长度为\(1\)是,答案是\(Yes\),当长度大于\(1\)时,如果有字符至少出现两次,则答案为\(Yes\). 时间复杂度:\(O(n)\) B. Weakened Common Divisor 题目描述:有\(n\)个数对,定义这\(n\)个数对的…
目录 Codeforces 1025 A.Doggo Recoloring B.Weakened Common Divisor C.Plasticine zebra D.Recovering BST(DP (bitset)) Codeforces 1025 比赛链接 为什么我room里的都不hack别人..那么明显的错.. A.Doggo Recoloring //只要能找到一个出现次数大于等于2的颜色就可以了.注意n=1特判.. #include <cstdio> #include <…
从这里开始 题目列表 瞎扯 Problem A Doggo Recoloring Problem B Weakened Common Divisor Problem C Plasticine zebra Problem D Recovering BST Problem E Colored Cubes Problem F Disjoint Triangles Problem G Company Acquisitions 瞎扯 打比赛,发现自己特别菜. 居然还苟且水上紫名 这个号不敢玩了.要努力学习…