-
Notifications
You must be signed in to change notification settings - Fork 0
/
alice_bob1.cpp
60 lines (49 loc) · 1000 Bytes
/
alice_bob1.cpp
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
48
49
50
51
52
53
54
55
56
57
58
59
60
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#define MAX 10000
using namespace std;
vector<int>::iterator it;
int main() {
int n;
//int list[MAX];
int temp1;
int count=0;
int result=0;
int *p;
vector<int>list;
cin>>n;
for(int i=0;i<n;++i) { cin>>temp1;
list.push_back(temp1);
++count; }
for(int i=0;i<n;++i) cout<< list[i]<<" ";
cout<<endl;
//start the game
bool flag=false;
while(1) {
++result;//Alice starts the game
flag=false;
for(int i=0;i<count;++i) {
for(int j=0;j<count;++j) {
if(i==j) continue;
int temp=abs(list[i]-list[j]);
//cout<<"Temp: "<<temp<<endl;
// p=find(list,list+count,temp);
it=find(list.begin(),list.end(),temp);
if(*it!=temp) { //not present n add the element
list.resize(count+1);
list[++count]=temp;
flag=true;
break;
}
}
if(flag) break;
}
if(flag==false) { //coudnt find such distinct number
if((result)%2==0) cout<<"Alice"<<endl;
else cout<<"Bob"<<endl;
break;
}
}
}