当前位置:网站首页>1148 werewolf - Simple Version (20 points)
1148 werewolf - Simple Version (20 points)
2022-06-30 14:55:00 【Xue Dongjing】
maxmin
1148 Werewolf - Simple Version (20 branch )
The question
Yes n A creature , There are two wolves , The others are people , Every creature says a word . Expressed as an integer . Negative numbers indicate wolves , A positive number means a person .-1 He thinks the first one is a wolf .+1 He thinks the first one is a man .
There is a wolf and a man lying among all creatures , Please find two wolves . Multiple results output the smallest number . No result output No Solution
Ideas
Make i j For the wolf , from 1,2 To n-1, n List two wolves .i,j For the wolf , The others are people .
Then judge the liar from the words of all creatures , If there are exactly two liars and one is a wolf , This situation meets the conditions .
Code
#include<stdio.h>
#include<vector>
using namespace std;
int main()
{
vector<int>p;
int x[10007],n,vis[10007];
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&x[i]);
}
for(int i=1;i<n;i++){
for(int j=i+1;j<=n;j++){
fill(vis,vis+n+1,1);
vis[i]=vis[j]=-1;
p.clear();
for(int k=1;k<=n;k++){
if(x[k]<0&&vis[-x[k]]>0||x[k]>0&&vis[x[k]]<0){
p.push_back(k);
}
}
if(p.size()==2&&vis[p[0]]+vis[p[1]]==0){
printf("%d %d\n",i,j);
return 0;
}
}
}
printf("No Solution\n");
return 0;
}
边栏推荐
- MV3 04_ Introducing Manifest V3
- Non decreasing column
- 左旋梯形螺纹的编程
- JS array sorting method summary
- Steps for commissioning of vertical machining center
- Examples of bubble sorting and matrix element screening in MATLAB
- ThinkPHP v3.2 comment annotation injection write shell
- Finding the median of two arrays by dichotomy
- Implement a long-click list pop-up box on apiccloud
- [extensive reading of papers] attributes guided facial image completion
猜你喜欢

Determine the number of digits of an integer in MATLAB (one line of code)

How to use Alibaba Vector Icon
![[buuctf] [actf2020 freshman competition]exec1](/img/af/22051a5feb3c1f6d7201a483bde127.jpg)
[buuctf] [actf2020 freshman competition]exec1

Learn about data kinship JSON format design from sqlflow JSON format

CCF numerical sorting (Full Score code + problem solving ideas + skill summary) 201503-2

CCF elimination games (Full Score code + problem solving ideas + skill summary) February 2, 2015

ThinkPHP show method parameter controllable command execution

Shift operator (detailed)

Solve the problem that codeblocks20.03 on win11 cannot run for the first time

After the MySQL service on the local computer is started and stopped, some services will automatically stop when they are not used by other services or programs
随机推荐
Implement a long-click list pop-up box on apiccloud
Why do high precision CNC machining centers have errors? You should pay attention to these four reasons!
Shangpinhui knowledge points of large e-commerce projects
V3 01_ Welcome
Matlab to find prime pairs within 100
Hbuilder most commonly used and full shortcut key set
ThinkPHP show method parameter controllable command execution
JS array sorting method summary
Greedy interval problem (5)
Three ways and differences of defining functions in JS
Determine the number of digits of an integer in MATLAB (one line of code)
@PathVariable
[extensive reading of papers] multimodal joint attribute prediction and value extraction for e-commerce product
Lost connection to the flow server (0 retries remaining): |Out of retries, exiting! Error reporting solution (flow)
Svn password forgetting solution
Computer screenshot how to cut the mouse in
Experiment 2: stack
Color classification of sorting
CCF date calculation (Full Score code + skill summary) February 2, 2015
Matlab construction operation example