-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path1089.cpp
More file actions
31 lines (30 loc) · 886 Bytes
/
1089.cpp
File metadata and controls
31 lines (30 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int stat[n + 1];
for (int i = 1; i <= n; i++)
cin >> stat[i];
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
int good = 0, evil = 0;
for (int k = 1; k <= n; k++) {
if (stat[k] > 0 && (stat[k] == i || stat[k] == j)) {
if (k == i || k == j) evil++;
else good++;
}
if (stat[k] < 0 && -stat[k] != i && -stat[k] != j) {
if (k == i || k == j) evil++;
else good++;
}
}
if (good == 1 && evil == 1) {
printf("%d %d\n", i, j);
return 0;
}
}
}
printf("No Solution\n");
return 0;
}