题意:每一个人 都有frist name 和 last name! 从每一个人的名字中任意选择 first name 或者 last name 作为这个人的编号!通过对编号的排序,得到每一个人 最终顺序!比较中的序列能否得到给定输出的序列一致! #include<iostream> #include<cstring> #include<cstdio> #include<string> #include<map> #include<algor…
C. Design Tutorial: Make It Nondeterministic time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A way to make a new task is to make it nondeterministic or probabilistic. For example, the hard…
Codeforces Round #270:C;http://codeforces.com/contest/472 题意:水题 题解:贪心即可. #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; ; int n; ]; ]; int a[N]; int main(){ scanf("%d",&…
题意:给定一个矩阵,表示每两个节点之间的权值距离,问是否可以对应生成一棵树, 使得这棵树中的任意两点之间的距离和矩阵中的对应两点的距离相等! 思路:我们将给定的矩阵看成是一个图,a 到 b会有多条路径, 如果存在一棵树,那么 这个树中a->b的距离一定是这个图中所有a->b中路径长度最短的一条!所以我们根据边权, 建立一棵MST树!再将MST树中的任意两点之间的距离求出来,看是否和矩阵中的对应的节点 对距离相同! #include<iostream> #include<cst…
题意:有一个电梯,每一个人都想乘电梯到达自己想要到达的楼层!从a层到b层的时间是|a-b|, 乘客上下电梯的时间忽略不计!问最少需要多少的时间....     这是一道神题啊,自己的思路不知不觉的就按照注解的思路走了,想着用优先队列模拟一下,可能还是没有模拟好吧,一直哇!但是同学的优先队列模拟过了! 没想到是greedy算法简单的几行就解决了! #include<iostream> #include<cmath> #include<cstdio> #include<…
题目链接 \(Description\) 给定两个长为\(n\)的数组\(x_i,y_i\).每次你可以选定\(i,j\),令\(x_i=x_i\ \mathbb{xor}\ x_j\)(\(i,j\)可以相等).要求若干次操作后使得\(x\)变成\(y\),输出方案.操作次数不能多于\(10^6\),无解输出\(-1\). \(n\leq10^4,\ 0\leq x_i,y_i\leq10^9\). \(Solution\) 考虑异或的两个基本性质: 异或是可逆的,逆运算就是它本身. 可以交换…
http://codeforces.com/contest/472/problem/D D. Design Tutorial: Inverse the Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There is an easy way to obtain a new task from an old on…
Design Tutorial: Learn from Life time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One way to create a task is to learn from life. You can choose some experience in real life, formalize it an…
D. Design Tutorial: Inverse the Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There is an easy way to obtain a new task from an old one called "Inverse the problem": we give…
B. Design Tutorial: Learn from Life time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One way to create a task is to learn from life. You can choose some experience in real life, formalize it…