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

跟着团子学SAP CO:揭秘结果分析码在项目结算中的实战应用(一)KKA2/CJ88 本文深入解析了SAP CO模块中结果分析码在项目结算中的核心作用。以KKA2(方法10)和事务代码CJ88为例,详细阐述了如何在项目完工后一次性确认收入的场景下,通过结果分析功能实现收入与成本的精准匹配,将项目成本暂估为在制品,确保各期利润的准确反映。 阅读详情

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.

Input Specification:

Each input file contains one test case. For each case, the first line gives a positive integer N (5≤N≤100). Then N lines follow and the i-th line gives the statement of the i-th player (1≤i≤N), which is represented by the index of the player with a positive sign for a human and a negative sign for a werewolf.

Output Specification:

If a solution exists, print in a line in ascending order the indices of the two werewolves. The numbers must be separated by exactly one space with no extra spaces at the beginning or the end of the line. If there are more than one solution, you must output the smallest solution sequence -- that is, for two sequences A=a[1],...,a[M] and B=b[1],...,b[M], if there exists 0≤k<M such that a[i]=b[i] (i≤k) and a[k+1]<b[k+1], then A is said to be smaller than B. In case there is no solution, simply print No Solution.

Sample Input 1:

5
-2
+3
-4
+5
+4

Sample Output 1:

1 4

Sample Input 2:

6
+6
+3
+1
-5
-2
+4

Sample Output 2 (the solution is not unique):

1 5

Sample Input 3:

5
-2
-3
-4
-5
-1

Sample Output 3:

No Solution

简单模拟。狼人杀的N个参赛者中有一名平民和一名狼人说谎,根据他们的描述,找出狼人。

思路:遍历所有可能性,验证每一名参赛者的说法在这种假设下的真伪,如果结果刚好是N-3名平民说真话、1名狼人说真话,则满足要求。 

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<cstring>
using namespace std;
const int MAX = 107;
int N;
int a[MAX];
bool W[MAX]={false};
bool judge(int x,int y){
	memset(W,false,sizeof(W));
	W[x]=true;W[y]=true;
	int humanCnt=0;int wolfCnt = 0;//说的真话 
	for(int i=1;i<=N;i++){
		if(!W[i]){//如果是平民 
			if((a[i]>0&&!W[a[i]])||(a[i]<0&&W[-a[i]])) humanCnt++;
		} 
		else{//如果是狼人 
			if((a[i]>0&&!W[a[i]])||(a[i]<0&&W[-a[i]])) wolfCnt++; 
		}
	}
	if(humanCnt==N-3&&wolfCnt==1) return true;
	else return false; 
}
int main(void){
	cin>>N;
	for(int i=1;i<=N;i++) cin>>a[i];
	for(int i=1;i<=N;i++){
		for(int j=i+1;j<=N;j++){
			if(judge(i,j)){
				cout<<i<<" "<<j;
				return 0;
			}
		}
	}
	cout<<"No Solution";
	return 0;
}

 

多个linux系统安装到一块硬盘(Kylin+UOS+ubuntu) 之前写过一篇类似的文档,笔者把kylin和UOS安装在一块硬盘上上一篇的文档地址多个linux系统安装到一块硬盘(Kylin+UOS)_银河麒麟系统和uos安装成双系统-优快云博客本次记录的是三个系统到一块硬件上银河麒麟:Kylin-Desktop-V10-SP1-Release-2107-arm64统信:uniontechos-desktop-20-professional-1050-arm64乌班图:ubuntu-22.04.5-live-server-arm64。 阅读详情

相关推荐

使用TensorFlow搭建FNN(全连接神经网络)的基本步骤

提示:转载请注明出处,若本文无意侵犯到您的合法权益,请及时与作者联系。 目录 一、定义神经网络的输入输出 二、搭建神经网络 1、定义一个神经层中的权重 2、定义一个神经层中的阈值 3、定义一个神经层中的激活函数 4、组合神经层为神经网络 三、搭建损失函数和优化器 1、搭建损失函数 首先介绍第一个函数这其中用到的共同的函数为 2、定义优化器 四、训练神经网络 全连接神经网络的网络结构如下: 一、定义神经网络的输入输出 神经网络最擅长的工作就是模拟非线性函数,即一个复杂的高..

qq_41959920的博客 4070

【题解】【PAT甲】1148 Werewolf - Simple Version (20 分)

题目链接 PTA | 程序设计类实验辅助教学平台 题目描述 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 ..

Elephant_King的博客 782

C++上机——2023年“信息与未来”小学生编程思维展示官方题解

本次活动前三题是“根据问题描述实现代码”类型的问题,题解和示例代码由人工智能GPT-4直接阅读题面后生成――只要熟悉C++的语法和基本的编程、调试,即可解决p1、p2、p3。后三题有一定的算法性,我们给出命题思路和一些可能的解法。注意:本题解是面向指导教师的;指导教师在讲解时可以根据学生掌握程度进行调整。

qq_39127687的博客 2297

Werewolf——困难版本

作业需求

Whtiewww的博客 553

LTspice元器件库导入与路径管理:符号、模型、子电路全解析

在电子电路仿真中,元器件库通常由符号、模型和子电路三层构成:符号定义引脚外观,模型描述电气行为,子电路封装多端子网络。理解三者职责边界,是解决 LTspice 元器件库导入报错的关键。许多导入失败并非软件问题,而是文件类型错配、路径引用不清或引脚顺序不一致。掌握 `.include` 指令、用户库搜索路径和自制符号绑定模型,可以提升第三方模型复用效率,降低跨项目迁移成本。该思路适用于运放、MOS 管、二极管等器件建模,尤其在 UA741 等经典运放导入场景中,需要先核对 `.subckt` 引脚顺序,再选择

weixin_29182481的博客 181

RPCA模型及GoDec算法

一、基础知识 在线性代数中,秩的物理意义是矩阵中最大的不相关的向量个数,因此秩可以用来度量相关性;而在图像处理中,秩就可以理解为图像中所包含的信息的丰富程度。图片中比较突兀的成分,会增加图像矩阵的秩,一幅清晰的自然图像其数据矩阵往往是低秩或者近似低秩的,这是因为其中的图像信息有很大的相关性,但如果图像中引入噪声,那么存在随机幅值任意大但是分布稀疏的误差破坏了原有数据的低秩性。 低秩矩阵:如果AAA是一个m×nm×nm×n的矩阵,rank(A)rank(A)rank(A)是矩阵AAA的秩,如果rank(A)

小席的学习日志 7690

PAT 甲级 1148  Werewolf - Simple Version

1148Werewolf - 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 sai...

漫浸天空的雨色的备忘录~ 810

WordPress MasterStudy LMS插件 SQL注入漏洞复现(CVE-2024-1512)

WordPress Plugin MasterStudy LMS 3.2.5 版本及之前版本存在安全漏洞,该漏洞源于对用户提供的参数转义不足,导致可以通过 /lms/stm-lms/order/items REST 路由的 user 参数进行基于联合的 SQL 注入。

0xSec 1443

Werewolf(狼人杀)DFS与回溯算法

看来结果还是很准确的()

shjsjdisi的博客 991

X书x-mini-sig_x-mini-mua

X书的tiny风控代码,成功运行x-mini-sig|x-mini-mua

Codeooo 博客 1万+

i.MX6ULL驱动开发 | 31 - Linux内核网络设备驱动框架

net_device结构体在内核中指代一个网络设备,定义在,是一个非常大的结构体,包含网络设备的属性描述和操作接口,其中一些关键的成员如下。Linux在轮询处理机制和中断处理机制的基础上,提出了一种高效的网络处理技术NAPI。NAPI的核心思想是不全部采用中断来读取网络数据,而是采用中断来唤醒数据接收服务程序,在接收服务程序中采用poll的方法来轮询处理数据。提高短数据包的接收效率,减少中断处理的时间。...

Mculover666的博客(嵌入式) 1104

「1148」Werewolf - Simple Version

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...

weixin_52435933的博客 443

fatal: unable to access ‘https://github.com/Stability-AI/stablediffusion.git/‘解决方案

本文主要介绍在安装 stable-diffusion-webui 时出现的 fatal: unable to access 'https://github.com/Stability-AI/stablediffusion.git/': Failed to connect to github.com port 443 after 21071 ms: Couldn't connect to server 问题的解决方案,希望能对你有所帮助。

水滴的博客 5688

PAT_甲级_1148 Werewolf - Simple Version (20point(s)) (C++)【模拟】

目录 1,题目描述 题目描述 2,思路 算法 3,AC代码 4,解题过程 1,题目描述 Sample Input 1: 5 -2 +3 -4 +5 +4 Sample Output 1: 1 4 Sample Input 2: 6 +6 +3 +1 -5 -2 +4 Sample Output 2 (the solution is not un...

&再见萤火虫&的博客 280

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

1148 Werewolf - Simple Version (20point(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:...

qq_42347617的博客 243

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

1148 Werewolf - Simple Version (20point(s)) - C语言 PAT 甲级

* 又是初看题目毫无头绪的题 1. 数组 v[101] 记录每个人说的话 2. 数组 a[101] 记录每次假设的实际身份,-1 为狼人,0 为好人 3. 每次假设后遍历一次每个人说的话,若和假设的身份冲突,说明此人说谎,添加至 lie[101] 4. 数组 lie[101] 最终有一个狼人和一个好人,则符合题目,否则,从第 2 步继续假设

有三只土豆 477

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

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

思路: 暴力破解,验证组合 {(i, j) | 1<=i<=N-1, i+1<=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 pl.

专栏 147

【PAT】A1148 Werewolf - Simple Version(20)

这里写自定义目录标题1148 Werewolf - Simple Version (20 point(s))Input Specification:Output Specification:Sample Input 1:Sample Output 1:Sample Input 2:Sample Output 2 (the solution is not unique):Sample Input 3...

Duke 234

PTA(A)1148 Werewolf - Simple Version (20point(s))(模拟)

思路: 遍历两个设为狼,然后根据发言,判断撒谎者。符合要求的就输出。 代码: #include <bits/stdc++.h> #include <cstdio> using namespace std; int a[101]; int main() { int n; cin >> n; int f = 0; for (int i = 1; i <= n; ++i) { cin >> a[.

Sqssq的博客 422

PAT甲级 -- 1148 Werewolf - Simple Version (20 分)

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...

猪の成长日记 205

1148 Werewolf - Simple Version

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...

张蔡辉 678

1148 Werewolf - Simple Version (20分)

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

白小飞 310

1148 Werewolf - Simple Version (20 分)

1148 Werewolf - Simple Version (20 分) 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: “Pla...

L_Aster的专栏 1371

PAT A1148

1148 Werewolf - Simple Version (20 分) 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: “Playe...

weixin_44539060的博客 352

PAT甲级1148 Werewolf - Simple Version

1148 柳神 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: "Playe

weixin_44535077的博客 308

1148 Werewolf - Simple Version (20)

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

2401_88085478的博客 693
上一篇: 1121 Damn Single (25 point(s))
下一篇: 1149 Dangerous Goods Packaging (25 point(s))
coderwait
博客等级 码龄9年 20粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值