CF763C Timofey and Remoduling】的更多相关文章

题目戳这里. 这道题目纯粹是考思维. 若\(2N \le M\),由于答案肯定是\(s,s+d,\dots,s+(N-1)d\),我们任意枚举两个数\(a,b\),不妨设\(b\)在数列中出现在\(a\)后面\(k\)位,设\(g = b-a\),则\(g\)这个差在所有数出现刚好\(N-K\)次.我们任取个\(g\),用二分或哈希求个差出现次数,就可以得知\(k\)了,然后\(d = gk^{-1}\).在检验数列中有\(a\)的公差为\(d\)的等差数列是否存在即可. 若\(2N > M\)…
题目大意: 告诉你一个长度为n的等差数列在模m意义下的乱序值(互不相等),问是否真的存在满足条件的等差数列,并尝试构造任意一个这样的数列. 思路: 首先我们可以有一个结论: 两个等差数列相等,当且仅当数字和与平方和分别相等. 首先求出一开始的数字和和平方和. 然后我们枚举每一个数作为首项的情况,求出这个数作为首项以后的数字和和平方和,根据数字和求出公差,然后用平方和检验一下. 然而这样并不能保证一定正确,但至少有大概率是正确的,我们可以O(n)的时间检验一下. 注意特判n=m的情况. #incl…
A. Timofey and a tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n…
地址:http://codeforces.com/contest/764/problem/D 题目: D. Timofey and rectangles time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One of Timofey's birthday presents is a colourbook in a shape o…
地址:http://codeforces.com/contest/764/problem/C 题目: C. Timofey and a tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Each New Year Timofey and his friends cut down a tree of n vertices…
地址:http://codeforces.com/contest/764/problem/B 题目: B. Timofey and cubes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Young Timofey has a birthday today! He got kit of n cubes as a birthd…
A. Timofey and a tree 题意:给一棵树,要求判断是否存在一个点,删除这个点后,所有连通块内颜色一样.$N,C \le 10^5$ 想法:这个叫换根吧.先求出一个点合法即其儿子的子树内颜色一样,非该点子树的点颜色都一样.可以用DFS序解决. #include< cstdio > typedef long long ll; template inline void read(T&x) { x=0;bool f=0;char c=getchar(); while((c&l…
C. Timofey and a tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Young Timofey has a birthday today! He got kit of n cubes as a birthday present from his parents. Every cube has a number ai, which is written on…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the…
Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci. Now it's time for Timofey birthday, and his mother asked him to remove the tre…
Young Timofey has a birthday today! He got kit of n cubes as a birthday present from his parents. Every cube has a number ai, which is written on it. Timofey put all the cubes in a row and went to unpack other presents. In this time, Timofey's elder…
题目戳这里. 首先题解给的是并查集的做法.这个做法很好想,但是很难码.用线段树数来维护并查集,暴力合并. 这里推荐另一个做法,可以无视\(K\)的限制.我们给每条边加个边权,这个边权为这条边左端点的值.然后我们将询问离线,按\(r\),从小到大处理. 对于当前询问\([l,r]\)我们用lct维护所有右端点\(\le r\)的边构成的最大生成树,然后用树状数组查询生成树中边权\(\ge l\)的边有几条即可. #include<algorithm> #include<iostream&g…
题目戳这里. 首先答案肯定是YES,因为一个平面图肯定可以被4种颜色染色,关键是怎么输出方案. 由于4是一个特殊的数字\(4 = 2^2\),而我们还有一个条件就是边长为奇数,而奇数是会改变二进制位的. 接下来我们这样思考,对于每个矩形我们设其左下角坐标为\((x,y)\),我们把他染成\((x\;mod\;2)\times2+(y\;mod\;2)\).由于边长是奇数,所以相邻矩形二进制位至少有一位不一样.然后这题就做完了. #include<iostream> #include<cs…
D题: 题目思路:给你n个不想交的矩形并别边长为奇数(很有用)问你可以可以只用四种颜色给n个矩形染色使得相接触的 矩形的颜色不相同,我们首先考虑可不可能,我们分析下最多有几个矩形互相接触,两个时可以都互相接触 三个时也可以互相接触,而四个时怎么摆我们都不能让他们相互都接触,所以我们最多可以用三种不同颜色 的矩形去接触另一个矩形,因此我们就一定可以用四种颜色来染色,然后我们来考虑怎么染色,因为不存在相 交的情况,所以就拿左下角来分析,首先我们来分析下, 1,两个矩形要上下接触时:我们考虑纵坐标,因…
标题写的树形DP是瞎扯的. 先把1看作根. 预处理出f[i]表示以i为根的子树是什么颜色,如果是杂色的话,就是0. 然后从根节点开始转移,转移到某个子节点时,如果其子节点都是纯色,并且它上面的那一坨结点也是纯色,就输出解. 否则如果其上面的一坨是纯色,并且其子节点有且只有一个杂色的时候,就递归处理该子节点. #include<cstdio> #include<cstdlib> using namespace std; #define N 100050 int v[N<<…
http://codeforces.com/contest/764/problem/C 题意:在n个顶点中随便删除一个,然后分成若干个连通子图,要求这若干个连通子图的颜色都只有一种. 记得边是双向的,wa15的可能是不知道边是双向的吧. 一个观察:如果某条边连接的两个顶点的颜色不同,那么可以看看删除这两个顶点,成立就成立,不成立就不成立. 因为必定要把这两个顶点分开. 然后就是暴力dfs了. #include <cstdio> #include <cstdlib> #include…
package codeforces; import java.util.*; public class CodeForces_764C_Timofey_and_a_tree { static final int N=(int) (2e5+10); @SuppressWarnings("unchecked") static ArrayList<Integer> a[]=new ArrayList[N]; static int book[]=new int[N]; stati…
[题目链接]:http://codeforces.com/contest/764/problem/D [题意] 给你n个矩形,以左下角坐标和右上角坐标的形式给出; (保证矩形的边长为奇数) 问你有没有染色方案,使得这n个矩形,任意两个相邻矩形的颜色不一样; (只有4种颜色可以选择); [题解] 因为矩形的边长为奇数; 所以对于左下角来说; 右上角的横纵坐标的奇偶性分别和左下角的横纵坐标的奇偶性都不同; (因为一个数加上奇数之后奇偶性发生改变); 按照这个原理; 我们只要考虑左下角那个坐标就好了:…
题目链接:http://codeforces.com/contest/764/problem/C 题意:给出一个树,然后各个节点有对应的颜色,问是否存在以一个点为根节点子树的颜色都一样. 这里的子树颜色都一样表示分出来的子树各自颜色一样. 就是随意找一个树叶节点然后一直遍历,直到找到一个和他颜色不一样的节点,那么要么取不一样的节点 为根或者取最后一个一样的节点为根.然后就dfs一遍. #include <iostream> #include <cstring> #include &…
呵呵呵,直接判断是不是一个点连起来所有的特殊边(连接2不同颜色的点的边) (一开始还想各种各样奇怪的dfs...垃圾) #include<bits/stdc++.h> #define LL long long #define N 100005 #define lowbit(x) x&(-x) using namespace std; inline int ra() { ,f=; char ch=getchar(); ; ch=getchar();} +ch-'; ch=getchar(…
%%题解,脑洞好大啊. 四色定理什么鬼的..所以一定是yes. 因为矩形边长都是奇数,所以可以按左下角分类,一共4类,分别1,2,3,4就可以了. (需要4种颜色的情况大概就是4个矩形围起来一个矩形) #include<bits/stdc++.h> #define LL long long #define N 100005 #define lowbit(x) x&(-x) using namespace std; inline int ra() { ,f=; char ch=getch…
Content 有一个序列 \(a_1,a_2,a_3,...,a_n\),对于 \(i\in[1,n]\),只要 \(i\leqslant n-i+1\),就把闭区间 \([i,n-i+1]\) 内的所有数翻转.现在给定你翻转后的序列,求原来的序列. 数据范围:\(1\leqslant n\leqslant 2\times 10^5,-10^9\leqslant a_i\leqslant 10^9\). Solution 做这题之前,我们来看这个序列的规律: 首先拿出一个序列 \([2,6,8…
A. Taymyr is calling you time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Comrade Dujikov is busy choosing artists for Timofey's birthday and is recieving calls from Taymyr from Ilia-alpinis…
2.2.2017 9:35~11:35 A - Taymyr is calling you 直接模拟 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; typedef long long ll; ; inline int read(){ ,f=; ; c=getcha…
引言: 前端代码是直接暴漏在浏览器中的,很多web攻击都是通过直接debug业务逻辑找到漏洞进行攻击,另外还有些喜欢“不劳而获”的分子暴力盗取他人网页简单修改后用来获利,总体上来说就是前端的逻辑太容易读懂了,本文主要基于JavaScript Obfuscator介绍一下前端混淆的基本思路. 一.JavaScript Obfuscator简介: JavaScript Obfuscator是Timofey Kachalov开发的一款JS混淆工具,传统的如uflifyJS等混淆工具主要都是用来压缩代码…
今天自己模拟了一套题,只写出两道来,第三道时间到了过了几分钟才写出来,啊,太菜了. A. Taymyr is calling you 水题,问你在z范围内  两个序列  n,2*n,3*n......  和 m,2*m,3*m.....有多少个是一样的. #include<bits/stdc++.h> using namespace std; int n,m,z; int main() { cin>>n>>m>>z; int gcd=__gcd(n,m);…
Description One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, b…
Description Young Timofey has a birthday today! He got kit of n cubes as a birthday present from his parents. Every cube has a number ai, which is written on it. Timofey put all the cubes in a row and went to unpack other presents. In this time, Timo…
Description Comrade Dujikov is busy choosing artists for Timofey's birthday and is recieving calls from Taymyr from Ilia-alpinist. Ilia-alpinist calls every n minutes, i.e. in minutes n, 2n, 3n and so on. Artists come to the comrade every m minutes,…