当前位置:网站首页>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;
}
边栏推荐
- Hbuilder most commonly used and full shortcut key set
- 2021-08-07 native and package types
- [extensive reading of papers] attributes guided facial image completion
- 【BUUCTF】[GXYCTF2019]Ping Ping Ping1
- Lfi-rce without controllable documents
- 立式加工中心的数控加工对刀具使用基本要求
- Error $(...) size is not a function
- Knowledge learned from the water resources institute project
- PS cutting height 1px, Y-axis tiling background image problem
- 1136: password translation
猜你喜欢

Matlab construction operation example

Knowledge learned from the water resources institute project

Att & CK red team evaluation field (I)

Shift operator (detailed)

CCF Z-scan (full mark code + problem solving ideas) 201412-2

How does hbuilder display in columns?
![【BUUCTF】[GXYCTF2019]Ping Ping Ping1](/img/dc/4d87dfb0c2fa9cd75b54e092fd3971.jpg)
【BUUCTF】[GXYCTF2019]Ping Ping Ping1

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

CCF image rotation (Full Score code + problem solving idea) 201503-01
![[buuctf] [geek challenge 2019] secret file](/img/00/23bebd013eb4035555c0057725e3c4.jpg)
[buuctf] [geek challenge 2019] secret file
随机推荐
Non decreasing column
2021-05-12
[extensive reading of papers] multimodal attribute extraction
[extensive reading of papers] multimodal joint attribute prediction and value extraction for e-commerce product
CCF access control system (Full Score code + problem solving idea) 201412-1
CCF call auction (full mark code + problem solving ideas + skill summary) 201412 - 3
PS dynamic drawing
Learn about data kinship JSON format design from sqlflow JSON format
[extensive reading of papers] analyzing connections between user attributes, images, and text
PHP recursive multi-level classification, infinite classification
CCF drawing (full mark code + problem solving ideas + skill summary) February 2, 2014
Three ways and differences of defining functions in JS
@PathVariable
Laravel upload error
Uniapp upload image method
1137: encrypted medical record
[untitled]
文本匹配——【NAACL 2022】GPL
How many questions can you answer for the interview of Mechanical Engineer?
Location of dichotomy