【codeforces 766E】Mahmoud and a xor trip】的更多相关文章

[题目链接]:http://codeforces.com/contest/766/problem/E [题意] 定义树上任意两点之间的距离为这条简单路径上经过的点; 那些点上的权值的所有异或; 求任意两点之间的距离和; [题解] 权值最大为1e6 所以每个点的权值的二进制形式最多20位左右; 则我们可以对权值的二进制形式的每一位独立考虑; 我们枚举第i位; 并且在计算的时候只考虑这第i位; 可以做树形dp; 算出穿过当前这个节点的路径(并且以其为lca->最高点) 异或和的二进制形式在第i为上权…
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard output Mahmoud wants to write a new dictionary that contains n words and relations between them. There are two types of relations: synonymy (i. e. the…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output While Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequence. They solved it, and then Ehab ch…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Mahmoud has n line segments, the i-th of them has length ai. Ehab challenged him to use exactly 3 line segments to form a non-degenerate triangl…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Mahmoud wrote a message s of length n. He wants to send it as a birthday present to his friend Moaz who likes strings. He wrote it on a magical…
题目链接 Mahmoud and a xor trip 树形DP.先考虑每个点到他本身的距离和,再算所有点两两距离和. 做的时候考虑二进制拆位即可. #include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i(0); i < (n); ++i) #define rep(i, a, b) for(int i(a); i <= (b); ++i) #define LL long long const…
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=2000),问满足[数列长度是k && 数列中每一个元素arr[i]在1~n之间 && 数列中元素可以重复]的数列有多少个?结果对10^9+7取余 解题思路:dp[i][j]表示长度是j,最后一位是i的种数 if(kk%i==0) dp[kk][j+1]+=dp[i][j] #inc…
E. Mahmoud and a xor trip 题目连接: http://codeforces.com/contest/766/problem/E Description Mahmoud and Ehab live in a country with n cities numbered from 1 to n and connected by n - 1 undirected roads. It's guaranteed that you can reach any city from an…
地址:http://codeforces.com/contest/766/problem/E 题目: E. Mahmoud and a xor trip time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mahmoud and Ehab live in a country with n cities numbered from …
[原题题面]传送门 [题面翻译]传送门 [解题思路] 操作涉及到区间求和和区间异或,考虑到异或操作,我们对每个数二进制分解. 把每一位单独提出来做,异或要么取反要么变为不变,对于每一位建一颗线段树,那么原题中的信息维护就相当于: 1.区间取反 2.区间求和 那就打标记传标记好了.. [code] #include<bits/stdc++.h> using namespace std; ; int n,q,abt,x,y,z; ][N]; ][N<<]; ][N<<],a…