|
| 1 | + |
| 2 | +// **************** Author : Tashin.Parvez *************************\ |
| 3 | +// **************** Updated: 21-06-23 *************************\ |
| 4 | +
|
1 | 5 | #include <bits/stdc++.h>
|
| 6 | +#define faster \ |
| 7 | + ios_base::sync_with_stdio(false); \ |
| 8 | + cin.tie(0); \ |
| 9 | + cout.tie(0); |
| 10 | +#define Read(x) freopen(x, "r", stdin) |
| 11 | +#define Write(x) freopen(x, "w", stdout) |
| 12 | +#define CRACKED return 0; |
| 13 | +#define nl "\n" |
| 14 | + |
| 15 | +// data_type_compressions : |
| 16 | +#define int long long |
| 17 | +#define ull unsigned long long |
| 18 | +#define ld long double |
| 19 | + |
| 20 | +#define PI 3.14159265358979323846 |
| 21 | + |
| 22 | +// I/O : |
| 23 | +#define loop(n) for (int i = 0; i < n; i++) // 0 to n Input or Output |
| 24 | +#define output(x) cout << x << nl // out |
| 25 | +#define printarray(arr, len) \ |
| 26 | + for (int i = 0; i < len; i++) \ |
| 27 | + { \ |
| 28 | + cout << arr[i] << " "; \ |
| 29 | + if (i + 1 == len) \ |
| 30 | + cout << endl; \ |
| 31 | + } // array print |
| 32 | + |
| 33 | +#define sq(x) ((x) * (x)) // x^2 square |
| 34 | +#define len(s) s.length() |
| 35 | +#define setDec(x) fixed << setprecision(x) |
| 36 | + |
| 37 | +#define YES printf("YES\n") |
| 38 | +#define Yes printf("Yes\n") |
| 39 | +#define NO printf("NO\n") |
| 40 | +#define No printf("No\n") |
| 41 | + |
2 | 42 | using namespace std;
|
3 |
| -int main() |
| 43 | + |
| 44 | +/* |
| 45 | + int n; cin>>n; |
| 46 | + int arr[n]; |
| 47 | + for(auto &v : arr) cin>>v; |
| 48 | +
|
| 49 | +
|
| 50 | + if(!(i&1)) //-------------- EVEN (for even --->> i&1 == 0) |
| 51 | + cout<<i<<nl; |
| 52 | +
|
| 53 | +*/ |
| 54 | + |
| 55 | +void solution() |
4 | 56 | {
|
5 |
| - int t; |
6 |
| - cin >> t; |
7 |
| - while (t--) |
| 57 | + int i, j, k, l, m, n, a, b, c, d, w, x, y, z, t, count = 0, index; |
| 58 | + string s; |
| 59 | + bool flag = false; |
| 60 | + char arr[4][4]; |
| 61 | + for (int i = 1; i < 4; i++) |
8 | 62 | {
|
9 |
| - char a[3][3]; |
10 |
| - for (int i = 0; i < 3; i++) |
11 |
| - for (int j = 0; j < 3; j++) |
12 |
| - cin >> a[i][j]; |
13 |
| - |
14 |
| - int flag = 1; |
15 |
| - |
16 |
| - char c; |
17 |
| - c = a[0][0]; |
18 |
| - if ((c == a[0][1] && c == a[0][2] && c != '.') || (c == a[1][0] && c == a[2][0] && c != '.') || |
19 |
| - (c == a[1][1] && c == a[2][2] && c != '.')) |
| 63 | + for (int j = 1; j < 4; j++) |
20 | 64 | {
|
21 |
| - cout << c << endl; |
22 |
| - flag = 0; |
| 65 | + cin >> arr[i][j]; |
23 | 66 | }
|
| 67 | + } |
| 68 | + string ans = "DRAW"; |
| 69 | + if (arr[1][1] != '.') |
| 70 | + { |
24 | 71 |
|
25 |
| - c = a[0][1]; |
26 |
| - if (c == a[1][1] && c == a[2][1] && c != '.') |
| 72 | + if (arr[1][1] == arr[1][2] && arr[1][1] == arr[1][3]) |
27 | 73 | {
|
28 |
| - cout << c << endl; |
29 |
| - flag = 0; |
| 74 | + ans = arr[1][1]; |
30 | 75 | }
|
31 |
| - c = a[1][0]; |
32 |
| - if (c == a[1][1] && c == a[1][2] && c != '.') |
33 |
| - { |
34 |
| - cout << c << endl; |
35 |
| - flag = 0; |
36 |
| - } |
37 |
| - c = a[2][0]; |
38 |
| - if (c == a[2][1] && c == a[2][2] && c != '.') |
| 76 | + |
| 77 | + if (arr[2][1] == arr[1][1] && arr[1][1] == arr[3][1]) |
39 | 78 | {
|
40 |
| - cout << c << endl; |
41 |
| - flag = 0; |
| 79 | + ans = arr[1][1]; |
42 | 80 | }
|
43 | 81 |
|
44 |
| - c = a[0][2]; |
45 |
| - if ((c == a[1][2] && c == a[2][2] && c != '.') || (c == a[1][1] && c == a[2][0] && c != '.')) |
| 82 | + if (arr[1][1] == arr[2][2] && arr[1][1] == arr[3][3]) |
46 | 83 | {
|
47 |
| - cout << c << endl; |
48 |
| - flag = 0; |
| 84 | + ans = arr[1][1]; |
49 | 85 | }
|
| 86 | + } |
50 | 87 |
|
51 |
| - if (flag == 1) |
52 |
| - cout << "DRAW" << endl; |
| 88 | + if (arr[1][2] != '.' && arr[1][2] == arr[2][2] && arr[1][2] == arr[3][2]) |
| 89 | + { |
| 90 | + ans = arr[1][2]; |
53 | 91 | }
|
54 |
| - return 0; |
| 92 | + |
| 93 | + if (arr[1][3] != '.' && arr[1][3] == arr[2][3] && arr[1][3] == arr[3][3]) |
| 94 | + { |
| 95 | + ans = arr[1][3]; |
| 96 | + } |
| 97 | + |
| 98 | + if (arr[1][3] != '.' && arr[1][3] == arr[2][2] && arr[1][3] == arr[3][1]) |
| 99 | + { |
| 100 | + ans = arr[1][3]; |
| 101 | + } |
| 102 | + |
| 103 | + if (arr[2][1] != '.' && arr[2][1] == arr[2][2] && arr[2][1] == arr[2][3]) |
| 104 | + { |
| 105 | + ans = arr[2][1]; |
| 106 | + } |
| 107 | + |
| 108 | + if (arr[3][1] != '.' && arr[3][1] == arr[3][2] && arr[3][1] == arr[3][3]) |
| 109 | + { |
| 110 | + ans = arr[3][1]; |
| 111 | + } |
| 112 | + cout << ans << nl; |
| 113 | +} |
| 114 | + |
| 115 | +int32_t main() |
| 116 | +{ |
| 117 | + faster; |
| 118 | + |
| 119 | + // #ifdef TashinParvez |
| 120 | + // Read("input.txt"); |
| 121 | + // // Write("output.txt"); |
| 122 | + // #endif // TashinParvez |
| 123 | + |
| 124 | + int t = 1; |
| 125 | + cin >> t; |
| 126 | + int c = 1; |
| 127 | + |
| 128 | + while (t--) |
| 129 | + { |
| 130 | + // cout << "Case " << c++ << ": "; |
| 131 | + solution(); |
| 132 | + } |
| 133 | + |
| 134 | + CRACKED; |
55 | 135 | }
|
0 commit comments