/home/toolbox/public_html/solutions/127/12700/a.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <fcntl.h>
6 #include <stdlib.h>
7 #include <math.h>
8 #include <stdint.h>
9
10 #define TRUE (1 == 1)
11 #define FALSE (1 != 1)
12
13 #define DEBUG if (FALSE)
14
15 /* fprintf(stderr, "functionName: message", varslist); */
16
17 /*
18 * Author: Isaac Traxler
19 * Date: 2015-10-01
20 * Purpose: fun
21 * Problem: 12700 - Banglawash
22 */
23
24 /*
25 * This template reads data a specified number of times.
26 */
27
28 #define MAX_GAMES 15
29
30 int numberOfTimes;
31 int games;
32 char buff[MAX_GAMES];
33 int W; /* games won by www */
34 int B; /* games won by Bangladesh */
35 int T; /* tie */
36 int A; /* abandons */
37
38 void init()
39 {
40 /* FUNCTION init */
41 scanf("%d ", &numberOfTimes);
42 } /* FUNCTION init */
43
44 void dump()
45 {
46 /* FUNCTION dump */
47 } /* FUNCTION dump */
48
49 void getInput()
50 {
51 /* FUNCTION getInput */
52 scanf(" %d %s ", &games, buff);
53 } /* FUNCTION getInput */
54
55 void process()
56 {
57 /* FUNCTION process */
58 int i;
59
60 W = 0;
61 B = 0;
62 T = 0;
63 A = 0;
64 for (i=0; i<games; i++)
65 {
66 /* for each game */
67 if ('W' == buff[i])
68 {
69 W++;
70 }
71 else if ('B' == buff[i])
72 {
73 B++;
74 }
75 else if ('T' == buff[i])
76 {
77 T++;
78 }
79 else if ('A' == buff[i])
80 {
81 A++;
82 }
83 } /* for each game */
84 if (games == A)
85 {
86 /* all abandoned */
87 printf("ABANDONED\n");
88 } /* all abandoned */
89 else if ((B + A) == games)
90 {
91 /* Bangladesh won all non-abandoned games */
92 printf("BANGLAWASH\n");
93 } /* Bangladesh won all non-abandoned games */
94 else if ((W + A) == games)
95 {
96 /* WWW won all non-abandoned games */
97 printf("WHITEWASH\n");
98 } /* WWW won all non-abandoned games */
99 else if (W == B)
100 {
101 /* draw */
102 printf("DRAW %d %d\n", B, T);
103 } /* draw */
104 else if (W > B)
105 {
106 /* WWW wins */
107 printf("WWW %d - %d\n", W, B);
108 } /* WWW wins */
109 else if (B > W)
110 {
111 /* Bangladesh wins */
112 printf("BANGLADESH %d - %d\n", B, W);
113 } /* Bangladesh wins */
114 else
115 {
116 /* should not be possible */
117 printf("Impossible\n");
118 B = W;
119 W = B / (B - W);
120 } /* should not be possible */
121
122 } /* FUNCTION process */
123
124 int main()
125 {
126 /* main */
127 int i;
128
129 init();
130 for (i=1; i<=numberOfTimes; i++)
131 {
132 /* while */
133 printf("Case %d: ", i);
134 getInput();
135 process();
136 } /* while */
137
138 return EXIT_SUCCESS;
139 } /* main */
140
141