-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1846B - Rudolph and Tic-Tac-Toe.cpp
70 lines (63 loc) · 1.52 KB
/
1846B - Rudolph and Tic-Tac-Toe.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
// ॐ नमः शिवाय
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
// Code Written By: Vikash Patel
// Codeforces Profile: https://codeforces.com/profile/vikashpatel
string solve(vector<vector<char>> m)
{
string d1, d2;
int k = -1;
for(int i=0; i<3; i++)
{
k++;
string s1, s2;
for(int j=0; j<3; j++)
{
s1 += m[i][j];
s2 += m[j][k];
if(i == j)
d1 += m[i][j];
}
if(s1 == "XXX" || s2 == "XXX")
return "X";
else if(s1 == "OOO" || s2 == "OOO")
return "O";
else if(s1 == "+++" || s2 == "+++")
return "+";
}
d2 += m[2][0];
d2 += m[1][1];
d2 += m[0][2];
if(d1 == "XXX" || d2 == "XXX")
return "X";
else if(d1 == "OOO" || d2 == "OOO")
return "O";
else if(d1 == "+++" || d2 == "+++")
return "+";
return "DRAW";
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("/Users/vikash/Desktop/output.txt", "w", stdout);
// #endif
int t;
cin>>t;
while(t--)
{
string a, b, c;
cin>>a>>b>>c;
vector<vector<char>> m = {{a[0], a[1], a[2]}, {b[0], b[1], b[2]}, {c[0], c[1], c[2]}};
cout<<solve(m)<<endl;
}
return 0;
}