当前位置:网站首页>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;
}
边栏推荐
- CCF numerical sorting (Full Score code + problem solving ideas + skill summary) 201503-2
- Programming exercises: whole point and circle (solution ideas and code implementation)
- Bucket sorting (C language)
- Experiment 2: stack
- Binary rotation array (1)
- NoViableAltException([email protected][])
- [untitled]
- Basic requirements for tool use in NC machining of vertical machining center
- 立式加工中心调试的步骤
- HD mechanical principle · classic dynamic drawing of mechanical design
猜你喜欢

Thinkphp5 log file contains trick

Matlab function for limit, definite integral, first-order derivative, second-order derivative (classic examples)

ctfshow nodejs

Laravel upload error

【BUUCTF】 EasySql

DiceCTF - knock-knock

CCF date calculation (Full Score code + skill summary) February 2, 2015

CCF drawing (full mark code + problem solving ideas + skill summary) February 2, 2014

DefCamp Capture the Flag (D-CTF) 2021-22 web

CCF image rotation (Full Score code + problem solving idea) 201503-01
随机推荐
机械工程师面试的几个问题,你能答上来几个?
Double pointer letter matching
Programming exercises: special numbers (problem solving ideas + code implementation)
Matlab finds prime numbers within 100
Computer screenshot how to cut the mouse in
HD mechanical principle · classic dynamic drawing of mechanical design
先锋期货安全么?现在期货开户都是哪些流程?期货手续费怎么降低?
Programming of left-hand trapezoidal thread
Summary of C language interview questions
Double pointer circular linked list
Color classification of sorting
Solve the problem that codeblocks20.03 on win11 cannot run for the first time
高清机械原理 · 机械设计经典动图
Text matching - [naacl 2021] augsbert
Non decreasing column
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
IO interview questions
[extensive reading of papers] sentimental analysis of online reviews with a hierarchical attention network
Implement a long-click list pop-up box on apiccloud
CCF image rotation (Full Score code + problem solving idea) 201503-01