超级大模拟 直接用map吧string对应到编号上来,然后在开个数组把每个编号对应到每个可以互相转化区块上来,预处理出区块的最小值,使用时直接取最小是即可 代码 #include <cstdio> #include <iostream> #include <map> #define ll long long #define min(a,b) ((a<b)?a:b) using namespace std; inline ll read(){ ll x = 0; i…
Mahmoud wants to send a message to his friend Ehab. Their language consists of n words numbered from 1 to n. Some words have the same meaning so there are k groups of words such that all the words in some group have the same meaning. Mahmoud knows th…
解法 又是一道结论题? 我的做法比较奇怪且没有证明 #include <cstdio> #include <cmath> #define ll long long int main(){ ll ans = 0; ll n, bs = 1; scanf("%I64d", &n); while (n > 1){ ans += (n >> 1) * bs; n -= (n >> 1); bs <<= 1; } prin…
Mahmoud and Ehab and yet another xor task 存在的元素的方案数都是一样的, 啊, 我好菜啊. 离线之后用线性基取check存不存在,然后计算答案. #include<bits/stdc++.h> #define LL long long #define LD long double #define ull unsigned long long #define fi first #define se second #define mk make_pair…
题意简述 一个数n,Mahmoud珂以取(即如果取\(k\),使\(n = n - k\))一个正偶数,Ehab珂以取一个正奇数,一个人如果不能取了(对于Mahmoud和Ehab \(n = 0\),对于Mahmoud \(n = 1\)),对方就赢了. Mahmoud先手,问谁会赢. 解法 很简单,如果n是奇数那么Mahmoud一次铁定取不玩,因为奇数减偶数为仍为奇数,所以剩下的肯定是奇数,那么Ehab讲把它取到0必胜:如果n为偶数Mahmoud一次去玩,Ehab必败. 简单来说,就是\(n\…
题目链接:Mahmoud and Ehab and the binary string 题意: 一道交互题,首先给出一个字符串的长度l.现在让你进行提问(最多15次),每次提问提出一个字符串,会返回这个字符串与目标串之间不同的字符的个数.要在15次的提问内,找到目标串中任意一个1和0的位置. 题解: 因为是15次提问,其实可以想到二分,但是分别对0和1进行二分差不多要二十多次,所以可以对01或10进行二分,查找某一个01或10串的位置. #include<bits/stdc++.h> usin…
A. Mahmoud and Ehab and the MEX time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Dr. Evil kidnapped Mahmoud and Ehab in the evil land because of their performance in the Evil Olympiad in In…
\(\color{#0066ff}{题目描述}\) 给出n个点,n-1条边,求再最多再添加多少边使得二分图的性质成立 \(\color{#0066ff}{输入格式}\) The first line of input contains an integer n - the number of nodes in the tree ( \(1<=n<=10^{5}\) ). The next n−1 lines contain integers u and v ( \(1<=u,v<=…
传送门:CF-862A A. Mahmoud and Ehab and the MEX time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Dr. Evil kidnapped Mahmoud and Ehab in the evil land because of their performance in the Evil Ol…
Mahmoud and Ehab continue their adventures! As everybody in the evil land knows, Dr. Evil likes bipartite graphs, especially trees. A tree is a connected acyclic graph. A bipartite graph is a graph, whose vertices can be partitioned into 2 sets in su…