1089 狼人杀-简单版 (20 分)

#include
#include
#include
using namespace std;
int main() {
	int n;
	cin>>n;
	vector<int> v(n+1);
	for(int i=1;i<=n;i++) {
		cin>>v[i];
	}
	for(int i=1;i<=n;i++) {
		for(int j=i+1;j<=n;j++) {
			vector<int> a(n+1, 1),lie;
			a[i]=-1;
			a[j]=-1;
			for(int k=1;k<=n;k++) {
				if(a[abs(v[k])]*v[k]<0) {
					lie.push_back(k);
				}
			}
			if(lie.size()==2&&a[abs(lie[0])]+a[abs(lie[1])]==0) {
				cout<<i<<" "<<j;
				return 0;
			}
		}
	}
	cout<<"No Solution";
	return 0;
}
@file: 1089 狼人杀-简单版 (20).py
@time: 2019/10/27 17:37
"""
import sys

n = int(input())
word = [0]
for g in range(n):
    word.append(int(input()))
for i in range(1, n+1):
    for j in range(i + 1, n+1):
        a = [1 for h in range(101)]
        lie = []
        a[i] = -1
        a[j] = -1
        for k in range(1, n+1):
            if word[k] * a[abs(word[k])] < 0:
                lie.append(k)
        if len(lie) == 2 and a[abs(lie[0])] + a[abs(lie[1])] == 0:
            print(i, j)
            sys.exit()
print("No Solution")

你可能感兴趣的:(1089 狼人杀-简单版 (20 分))