首页 > TAG信息列表 > Ehab

CF1325F Ehab's Last Theorem

传送门 思路 dfs 树的一道出色的应用题 令 \(k=\lceil \sqrt n \rceil\) 我们先按照遍历的顺序构建出 dfs 树 对于一条返祖边 \((u, v)\),如果有 \(dep_u-dep_v +1\ge k\),那么 dfs 树上的链 \((v, u)\) 就是一个满足要求的环 假如并没有满足要求的环,说明对于从根出发的链上任意两

cf1364 D. Ehab's Last Corollary / cf1325 F. Ehab's Last Theorem(DFS树,环)

题意: 给定一个无向连通图,你需要解决以下两个问题之一: 1364D: 找出一个大小为 \(\lceil \frac k2\rceil\) 的独立点集 找出一个大小不超过 \(k\) 的环 1325F: 找出一个大小为 \(\lceil \sqrt n\rceil\) 的独立点集 找出一个不小于 \(\lceil \sqrt n\rceil\) 的环 独立点集中,

CF1088F Ehab and a weird weight formula

题面 给定一棵树,点有点权,其中这棵树满足除了权值最小的点外,每个点都有一个权值比它小的点与它相邻。 要求你重新构建这棵树,使得代价最小。计算代价的方法如下: 现在规定: 一个点的代价为:\(\text{deg}_u \times a_u\),其中 \(\text{deg}_u\) 表示点 \(u\) 的度数,即与 \(u\) 直接相连

CF862C Mahmoud and Ehab and the xor 题解

Link. Codeforces Luogu Description. 给你一个数 \(x\) 问你能不能分解成 \(n\) 个互不相同的数,使得这 \(n\) 个数的异或和为 \(x\)。 Solution. Corner Case 太多了 首先,一眼秒,直接前前 \(n-2\) 个是 \(i\),然后最后两个是 \(x\oplus 2^{17}\oplus \bigoplus_{i=1}^{n-2}i\) 和

CF1514E - Baby Ehab's Hyper Apartment

CF1514E - Baby Ehab's Hyper Apartment 题目大意 交互题,给定\(n\)元竞赛图,方向未知,通过两种操作 1.查询\((a,b)\)方向 ,上限\(9n\)次 2.查询\(a\)到达一个集合\(S\)是否存在正向边,上限\(2n\)次 判定所有点之间能否互相到达 分析 能否互相到达是一个强连通问题,因此需要求出分量以

C. Baby Ehab Partitions Again

C. Baby Ehab Partitions Again 题目链接 题目大意 给你一个长度为n的序列要求你使得这个序列无论怎么划分成两个子序列,其和都不会相等。要求你输出这个序列中需要删除元素的下标。 思路 当原序列的和为奇数时不需要删除,这个序列无论怎么划分都不会出现相等的情况,如果为偶数,

D. Ehab the Xorcist

D. Ehab the Xorcist time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Given 2 integers uu and vv, find the shortest array such that bitwise-xor of its elements is uu, and the sum of

#628 (Div. 2)——D. Ehab the Xorcist

D. Ehab the Xorcist   Given 2 integers uu and vv, find the shortest array such that bitwise-xor of its elements is uu, and the sum of its elements is vv. Input The only line contains 2 integers uu and vv (0≤u,v≤1018)(0≤u,v≤1018). Outp

题解 CF1325A 【EhAb AnD gCd】

\(Solution:\) 这道题的问题是输出一组 \((a,b)\) 使得 \(\gcd(a,b)+\operatorname{lcm}(a,b)=x\),我们又知道 \(\gcd(a,1)=1\),\(\operatorname{lcm}(a,1)=a\) 又知道如果有多种可能就输出其中一种即可,所以我们就直接输出 $1,x-1$ 就行了。 \(code:\) #include<cstdio>//这里为了

Codeforces - 1325D - Ehab the Xorcist(构造)

题目链接 题目大意:给你俩数\(u\)和\(v\),问你是否能找出来最短的一列数,使它们的和为\(v\),异或值为\(u\)。   这题主要是考察对位运算的理解。   1.首先,位运算是不存在进位的,所以位运算的结果只会比原来的和小,也就是说\(u\)绝对不会大于\(v\)。   2.如果异或后的结果是奇数的

D. Ehab the Xorcist

题意: 略; 感觉被演了一波,这是CFdiv2吗? 算是这个构造题吧。 1 首先我们可以将u进行二进制拆分来考虑。加入u>v那么小与v的那些数在怎么拼接也无法使异或值为u。 比如二进制U=1 0 1 1 0。怎么才能异或成这个数呢?无非就是让1所在的位置的1的个数为奇数就行了,也就是构成异或成U的最小

cf 1174 D Ehab and the Expected XOR Problem

cf 1174 D Ehab and the Expected XOR Problem 题意 在1~\(2^n\)范围内找到一个最长的序列,使得该序列的每一个子串异或后不等于0和x 题解 假设该序列为a,那么前缀异或和b[i] = a[i]^a[i-1]^...^a[0],如果b之间异或都不会等于0和x,那么a之间也不会。 #include <cstdio> #include <cstr

CF1174F Ehab and the Big Finale

https://codeforces.com/contest/1174/problem/F   #include<bits/stdc++.h>using namespace std;const int maxn=2e5+5;vector<int> v[maxn],h;int sz[maxn],dep[maxn],depx;//sz数组存储以i为根节点的树拥有多少结点(包括i本身)int pre(int node,int p){ sz[node]=1; for(

D. Ehab and the Expected XOR Problem

链接 [https://codeforces.com/contest/1174/problem/D] 题意 让你构造一个数组,使得任意子段异或和不为0也不为x,而且每个数字大于等于1小于(1<<n) 分析 比赛做不出来,还是太垃圾了,这只能说水平不够。而且我对位运算的题真的不敏感。 以后专门刷下位运算题。 我是看官方题解,知道的。

A. Ehab Fails to Be Thanos

链接:https://codeforces.com/contest/1174/problem/A 题意: You're given an array aa of length 2n2n. Is it possible to reorder it in such way so that the sum of the first nn elements isn't equal to the sum of the last nn elements? 思路: 排序后求前一半和后一

B. Ehab Is an Odd Person

链接:https://codeforces.com/contest/1174/problem/B 题意: You're given an array aa of length nn. You can perform the following operation on it as many times as you want: Pick two integers ii and jj (1≤i,j≤n)(1≤i,j≤n) such that ai+ajai+aj is odd, th

C. Ehab and a Special Coloring Problem

链接:https://codeforces.com/contest/1174/problem/C 题意: You're given an integer nn. For every integer ii from 22 to nn, assign a positive integer aiai such that the following conditions hold: For any pair of integers (i,j)(i,j), if ii and jj are c

Codeforces 1174B Ehab Is an Odd Person

题目链接:http://codeforces.com/problemset/problem/1174/B 题意:给定长度 n 的数组,任意俩个相加为奇数的数可以交换数组中的位置,让这个数组尽量从小到大。 思路:不难发现只要 2 个数奇偶性不同就可以交换 ,对于纯奇数或纯偶数数组,它们是没办法交换任何数,原样输出即可。不是纯奇偶的