UVa11063

題目:
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=22&page=show_problem&problem=2004

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <set>
#include <algorithm>

using namespace std;

int main(){
int n;
int cases = 0;
while(cin >> n){
++cases;
int arr[n];
for(int i=0; i<n; ++i) cin >> arr[i];

bool isB2 = true;

for(int i=0; i<n; ++i){
if(arr[i] < 1){
isB2 = false;
break;
}
}

for(int i=1; i<n; ++i){
if(arr[i] < arr[i-1]){
isB2 = false;
break;
}
}

set<int> s;
for(int i=0; i<n; ++i){
for(int j=i; j<n; ++j){
int num = arr[i]+arr[j];
if(s.count(num)>=1){
isB2 = false;
break;
}
s.insert(num);
}
}
if(isB2) cout << "Case #" << cases << ": It is a B2-Sequence.\n";
else cout << "Case #" << cases << ": It is not a B2-Sequence.\n";
cout << '\n';
}
return 0;
}