1148 Werewolf - Simple Version (20 point(s))

思路:

暴力破解,验证组合 {(i, j) |  1<=i<j<=N},是否满足给定条件:

1个狼人说谎,另外一个狼人不说谎,还有1个平民说谎(at least one but not all the werewolves were lying)

组合 (i,j)就是解,没有就是无解。

1148 Werewolf - Simple Version (20 point(s))

Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game,

  • player #1 said: "Player #2 is a werewolf.";
  • player #2 said: "Player #3 is a human.";
  • player #3 said: "Player #4 is a werewolf.";
  • player #4 said: "Player #5 is a human."; and
  • player #5 said: "Player #4 is a human.".

Given that there were 2 werewolves among them, at least one but not all the werewolves were lying, and there were exactly 2 liars. Can you point out the werewolves?

Now you are asked to solve a harder version of this problem: given that there were N players, with 2 werewolves among them, at least one but not all the werewolves were lying, and there were exactly 2 liars. You are supposed to point out the werewolves.

Example:

#include<iostream>
#include<cmath>
#include<vector>
#include<set>
using namespace std;

int main()
{
    int  N;
    cin >> N;
    vector<int> player(N+1);
    for(int i = 1; i <= N; i++) cin >> player[i];
    vector<int> real(N+1, 1);
    for(int i = 1; i <= N-1; i++) {
        real[i] = -1;
        for(int j = i+1; j <= N; j++) {
            set<int> lies;
            lies.clear();
            real[j] = -1;
            for(int k = 1; k <= N; k++) 
                if(real[abs(player[k])] * player[k] < 0) lies.insert(k);
            if(lies.size() == 2 && (lies.count(i) + lies.count(j) == 1)) {
                cout << i << ' ' << j;
                return 0;
            }
            real[j] = 1;
        }
        real[i] = 1;
    }
    cout << "No Solution";
}

 

内容概要:本文详细探讨了基于樽海鞘算法(SSA)优化的极限学习机(ELM)在回归预测任务中的应用,并与传统的BP神经网络、广义回归神经网络(GRNN)以及未优化的ELM进行了性能对比。首先介绍了ELM的基本原理,即通过随机生成输入层与隐藏层之间的连接权重及阈值,仅需计算输出权重即可快速完成训练。接着阐述了SSA的工作机制,利用樽海鞘群体觅食行为优化ELM的输入权重和隐藏层阈值,从而提高模型性能。随后分别给出了BP、GRNN、ELM和SSA-ELM的具体实现代码,并通过波士顿房价数据集和其他工业数据集验证了各模型的表现。结果显示,SSA-ELM在预测精度方面显著优于其他三种方法,尽管其训练时间较长,但在实际应用中仍具有明显优势。 适合人群:对机器学习尤其是回归预测感兴趣的科研人员和技术开发者,特别是那些希望深入了解ELM及其优化方法的人。 使用场景及目标:适用于需要高效、高精度回归预测的应用场景,如金融建模、工业数据分析等。主要目标是提供一种更为有效的回归预测解决方案,尤其是在处理大规模数据集时能够保持较高的预测精度。 其他说明:文中提供了详细的代码示例和性能对比图表,帮助读者更好地理解和复现实验结果。同时提醒使用者注意SSA参数的选择对模型性能的影响,建议进行参数敏感性分析以获得最佳效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值