forked from bnslakki/Spoj
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCARRHIM.cpp
137 lines (129 loc) · 2.99 KB
/
CARRHIM.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include "bits/stdc++.h"
using namespace std;
int main()
{
//INPUT;
bool f = false;
int w = 0, b = 0;
char c[2], team_red='#',initial_team;
while (scanf("%s",c)!=EOF)
{
if (c[0] != '#')
{
if (f==false)
{
initial_team = c[0];
f = true;
}
int arr[4];
for (int i = 0; i<3; i++)
{
scanf("%d", &arr[i]);
}
w += arr[0];
b += arr[1];
if (arr[2] == 1)
{
team_red = c[0];
}
//
}
else
{
//printf("%d %d\n", w, b);
/*case 1- when team 1 take all their pawns but team 2 not
either 2 of them cover red pawn must */
/*case 2- when team 2 take all their pawn but team 1 not
either 2 of them cover red pawn must */
/*case 3- when none of team cover their all 9 pawns*/
/*case 4- when team 1 take all their pawns but team 2 not
but none of them cover red pawn*/
/*case 5- when team 2 take all their pawns but team 1 not
but none of them cover red pawn*/
/*case 6- when both of them cover their all pawns and none of them
cover red pawn*/
/*case 7- when both of them cover their all pawns but team 1 cover red pawn*/
/*case 8- when both of them cover their all pawns but team 2 cover red pawn*/
/* team 1- A and C team 2 - B and D */
if (w == 9 && b != 9 && team_red != '#')
{
if (initial_team == 'A' || initial_team == 'C')
{
// team 1
if (team_red == 'A' || team_red == 'C')
printf("Team-1 win and the point is %d.\n", 9 - b + 5);
else
{
printf("Team-1 win and the point is %d.\n", 9 - b);
}
}
else
{
// team 2
if (team_red == 'B' || team_red == 'D')
printf("Team-2 win and the point is %d.\n", 9 - b + 5);
else
{
printf("Team-2 win and the point is %d.\n", 9 - b);
}
}
}
else if (w != 9 && b == 9 && team_red != '#')
{
if (initial_team == 'A' || initial_team == 'C')
{
// team 1
if (team_red == 'A' || team_red == 'C')
printf("Team-2 win and the point is %d.\n", 9 - w );
else
{
printf("Team-2 win and the point is %d.\n", 9 - w + 5);
}
}
else
{
// team 2
if (team_red == 'B' || team_red == 'D')
printf("Team-1 win and the point is %d.\n", 9 - w);
else
{
printf("Team-1 win and the point is %d.\n", 9 - w + 5);
}
}
}
else if (w != 9 && b != 9)
{
printf("Incomplete game.\n");
}
else if (w == 9 && b != 9 && team_red == '#')
{
printf("Incomplete game.\n");
}
else if (w != 9 && b == 9 && team_red == '#')
{
printf("Incomplete game.\n");
}
else if (w == 9 && b == 9 && team_red == '#')
{
printf("Incomplete game.\n");
}
else if (w == 9 && b == 9 && team_red != '#')
{
if (team_red == 'A' || team_red == 'C')
printf("Team-1 win and the point is 5.\n");
else
{
printf("Team-2 win and the point is 5.\n");
}
}
else
{
printf("Incomplete game.\n");
}
f = false;
w = 0, b = 0;
team_red = '#';
}
}
return 0;
}