-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathc.cpp
62 lines (55 loc) · 1.21 KB
/
c.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
61
62
#include <bits/stdc++.h>
using namespace std;
int combination(char arr[], int n)
{
int ans = 0;
for (int i = 0; i < n; i++)
{
string s(1, arr[i]);
for (int j = i + 1; j < n; j++)
{
s += arr[j];
if (s[0] != arr[j])
{
for (int k = j + 1; k < n; k++)
{
if (s[1] != arr[k])
{
ans++;
}
}
}
s = string(1, arr[i]);
}
}
return ans;
}
int main()
{
string ashok, anand;
getline(cin, ashok);
getline(cin, anand);
char as[ashok.size() + 1];
char an[anand.size() + 1];
strcpy(as, ashok.c_str());
strcpy(an, anand.c_str());
int placementlelo_as = combination(as, ashok.size());
int placementlelo_an = combination(an, anand.size());
if (placementlelo_as == 0 && placementlelo_an == 0)
{
cout << "Invalid input";
}
else if (placementlelo_as > placementlelo_an)
{
cout << "Ashok";
}
else if (placementlelo_an > placementlelo_as)
{
cout << "Anand";
}
else
{
cout << "Draw";
}
return 0;
}