The 2010 ACM-ICPC Asia Chengdu Regional Contest

本文解析了三项ACM竞赛题目,包括二进制数比对、误差曲线最小化及相似度计算,涵盖模拟算法、三分法查找及KM最优匹配算法等关键技术。

 The 2010 ACM-ICPC Asia Chengdu Regional Contest - C

Binary Number


Time Limit: 2 Seconds      Memory Limit: 65536 KB


For 2 non-negative integers x and y, f(x, y) is defined as the number of different bits in the binary format of x and y. For example, f(2, 3)=1, f(0, 3)=2, f(5, 10)=4.

Now given 2 sets of non-negative integers A and B, for each integer b in B, you should find an integer a in A such that f(a, b) is minimized. If there are more than one such integers in set A, choose the smallest one.

Input

The first line of the input is an integer T (0 < T ≤ 100), indicating the number of test cases. The first line of each test case contains 2 positive integers m and n (0 < m, n ≤ 100), indicating the numbers of integers of the 2 sets A and B, respectively. Then follow (m + n) lines, each of which contains a non-negative integers no larger than 1000000. The first m lines are the integers in set A and the other n lines are the integers in set B.

Output

For each test case you should output n lines, each of which contains the result for each query in a single line.

Sample Input

2

2 5

1

2

1

2

3

4

5

5 2

1000000

9999

1423

3421

0

13245

353

 

Sample Output

1

2

1

1

1

9999

0

 

纯模拟

 

 

The 2010 ACM-ICPC Asia Chengdu Regional Contest - F

Error Curves


Time Limit: 2 Seconds      Memory Limit: 65536 KB


Josephina is a clever girl and addicted to Machine Learning recently. She pays much attention to a method called Linear Discriminant Analysis, which has many interesting properties.

In order to test the algorithm's efficiency, she collects many datasets. What's more, each data is divided into two parts: training data and test data. She gets the parameters of the model on training data and test the model on test data.

To her surprise, she finds each dataset's test error curve is just a parabolic curve. A parabolic curve corresponds to a quadratic function. In mathematics, a quadratic function is a polynomial function of the form f(x) = ax2 + bx + c. The quadratic will degrade to linear function if a = 0.

 

 

 

It's very easy to calculate the minimal error if there is only one test error curve. However, there are several datasets, which means Josephina will obtain many parabolic curves. Josephina wants to get the tuned parameters that make the best performance on all datasets. So she should take all error curves into account, i.e., she has to deal with many quadric functions and make a new error definition to represent the total error. Now, she focuses on the following new function's minimal which related to multiple quadric functions.

The new function F(x) is defined as follow:

F(x) = max(Si(x)), i = 1...n. The domain of x is [0, 1000]. Si(x) is a quadric function.

Josephina wonders the minimum of F(x). Unfortunately, it's too hard for her to solve this problem. As a super programmer, can you help her?

Input

The input contains multiple test cases. The first line is the number of cases T (T < 100). Each case begins with a number n(n ≤ 10000). Following n lines, each line contains three integers a (0 ≤ a ≤ 100), b (|b| ≤ 5000), c (|c| ≤ 5000), which mean the corresponding coefficients of a quadratic function.

Output

For each test case, output the answer in a line. Round to 4 digits after the decimal point.

Sample Input
2
1
2 0 0
2
2 0 0
2 -4 2
Sample Output
0.0000
0.5000
分析得,出现最小指的地方必然是函数相交的地方,但是求函数两两相交的交点必然超时
注意到范围[0,1000],而且F(i)在出现最小值的x左右两侧都是单调的
所以用三分解决……
 

The 2010 ACM-ICPC Asia Chengdu Regional Contest - J

Similarity


Time Limit: 2 Seconds      Memory Limit: 65536 KB


When we were children, we were always asked to do the classification homework. For example, we were given words {Tiger, Panda, Potato, Dog, Tomato, Pea, Apple, Pear, Orange, Mango} and we were required to classify these words into three groups. As you know, the correct classification was {Tiger, Panda, Dog}, {Potato, Tomato, Pea} and {Apple, Pear, Orange, Mango}. We can represent this classification with a mapping sequence {A,A,B,A,B,B,C,C,C,C}, and it means Tiger, Panda, Dog belong to group A, Potato, Tomato, Pea are in the group B, and Apple, Pear, Orange, Mango are in the group C.

But the LABEL of group doesn't make sense and the LABEL is just used to indicate different groups. So the representations {P,P,O,P,O,O,Q,Q,Q,Q} and {E,E,F,E,F,F,W,W,W,W} are equivalent to the original mapping sequence. However, the representations {A,A,A,A,B,B,C,C,C,C} and {D,D,D,D,D,D,G,G,G,G} are not equivalent.

The pupils in class submit their mapping sequences and the teacher should read and grade the homework. The teacher grades the homework by calculating the maximum similarity between pupils' mapping sequences and the answer sequence. The definition of similarity is as follow.

Similarity(S, T) = sum(Si == Ti) / L

L = Length(S) = Length(T), i = 1, 2,... L, where sum(Si == Ti) indicates the total number of equal labels in corresponding positions.

The maximum similarity means the maximum similarities between S and all equivalent sequences of T, where S is the answer and fixed.

Now given all sequences submitted by pupils and the answer sequence, you should calculate the sequences' maximum similarity.

Input

The input contains multiple test cases. The first line is the total number of cases T (T < 15). The following are T blocks. Each block indicates a case. A case begins with three numbers n (0 < n < 10000), k (0 < k < 27), m (0 < m < 30), which are the total number of objects, groups, and students in the class. The next line consists of n labels and each label is in the range [A...Z]. You can assume that the number of different labels in the sequence is exactly k. This sequence represents the answer. The following are m lines, each line contains n labels and each label also is in the range [A...Z]. These m lines represent the m pupils' answer sequences. You can assume that the number of different labels in each sequence doesn't exceed k.

Output

For each test case, output m lines, each line is a floating number (Round to 4 digits after the decimal point). You should output the m answers in the order of the sequences appearance.

Sample Input

2

10 3 3

A A B A B B C C C C

F F E F E E D D D D

X X X Y Y Y Y Z Z Z

S T R S T R S T R S

3 2 2

A B A

C D C

F F E

Sample Output

1.0000

0.7000

0.5000

1.0000

0.6667

 

KM最优匹配,将标准答案串T与输入串S的每一位连线

左右各26个字母,求最大匹配。

内容概要:本文围绕并网与离网模式下的风光互补制氢合成氨系统,开展容量配置与调度优化的建模与仿真研究,基于Python代码实现核心技术复现。研究聚焦于风能与太阳能发电的波动性特征,结合电解水制氢及氢气合成氨的能量转换环节,构建综合能源系统的多目标优化模型,兼顾经济性、能源利用率与系统稳定性。通过引入先进的优化算法与Cplex等求解工具,对系统关键设备容量进行优化配置,并实现多时段运行调度的精细化决策,推动可再生能源高效转化为绿色化工产品,为“电-氢-氨”一体化系统的设计与运行提供科学依据和技术支撑。; 适合人群:具备一定Python编程能力和优化建模基础,从事新能源系统、氢能利用、综合能源系统规划与运行等方向研究的科研人员、高校研究生及工程技术人员。; 使用场景及目标:①用于风光制氢合成氨系统的容量规划、运行策略制定与经济性评估;②支撑高水平学术论文的模型复现、算法验证与创新研究,提升对多能互补系统协同优化机制的理解与实践能力; 阅读建议:建议结合Cplex等优化求解器运行代码,深入理解模型构建过程中的目标函数设计与约束条件表达,重点关注可再生能源出力不确定性处理与能量转换效率建模,并参考相关文献进一步拓展优化算法与场景分析维度。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值