Skip to content

Commit e2a8825

Browse files
committed
B_Rudolph_and_Tic_Tac_Toe
1 parent 5ce3cd1 commit e2a8825

6 files changed

+164
-40
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"name":"B. Rudolph and Tic-Tac-Toe","group":"Codeforces - Codeforces Round 883 (Div. 3)","url":"https://codeforces.com/contest/1846/problem/B","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"input":"5\n+X+\nOXO\nOX.\nO+.\n+OX\nX+O\n.XO\nOX.\n+++\nO.+\nX.O\n+..\n.++\nX.O\n+..","output":"X\nO\n+\nDRAW\nDRAW","id":1688747916819},{"id":1688748124463,"input":"1\n+++\n...\nXXX","output":""}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"BRudolphAndTicTacToe"}},"batch":{"id":"5ff73e5d-39ee-4f02-88c8-0816ad2fbad0","size":1},"srcPath":"d:\\Competitive_Programming_Journey\\Codeforces_Solutions\\B_Rudolph_and_Tic_Tac_Toe.cpp"}
1+
{"name":"B. Rudolph and Tic-Tac-Toe","group":"Codeforces - Codeforces Round 883 (Div. 3)","url":"https://codeforces.com/problemset/problem/1846/B","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1688916428597,"input":"5\n+X+\nOXO\nOX.\nO+.\n+OX\nX+O\n.XO\nOX.\n+++\nO.+\nX.O\n+..\n.++\nX.O\n+..","output":"X\nO\n+\nDRAW\nDRAW"},{"id":1688918319491,"input":"1\nXXX\n...\nXXX","output":""}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"BRudolphAndTicTacToe"}},"batch":{"id":"4680d87b-0f26-462e-8c3c-292d460440ee","size":1},"srcPath":"d:\\Competitive_Programming_Journey\\Codeforces_Solutions\\B_Rudolph_and_Tic_Tac_Toe.cpp"}

Codeforces_Solutions/.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"cmath": "cpp",
55
"random": "cpp",
66
"regex": "cpp",
7-
"istream": "cpp"
7+
"istream": "cpp",
8+
"ostream": "cpp"
89
}
910
}
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,135 @@
1+
2+
// **************** Author : Tashin.Parvez *************************\
3+
// **************** Updated: 21-06-23 *************************\
4+
15
#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+
242
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()
456
{
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++)
862
{
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++)
2064
{
21-
cout << c << endl;
22-
flag = 0;
65+
cin >> arr[i][j];
2366
}
67+
}
68+
string ans = "DRAW";
69+
if (arr[1][1] != '.')
70+
{
2471

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])
2773
{
28-
cout << c << endl;
29-
flag = 0;
74+
ans = arr[1][1];
3075
}
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])
3978
{
40-
cout << c << endl;
41-
flag = 0;
79+
ans = arr[1][1];
4280
}
4381

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])
4683
{
47-
cout << c << endl;
48-
flag = 0;
84+
ans = arr[1][1];
4985
}
86+
}
5087

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];
5391
}
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;
55135
}
Binary file not shown.

Codeforces_Solutions/FOR_TEMPLATE_TASHIN.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ using namespace std;
55

66
// 1 . arraysort
77
// 2. reverse sort
8+
// 3. three number equal check
89

910
#define printarray(arr, len) for (int i = 0; i < len; i++) cout << a[i] << " "; cout << endl; // array print
1011
#define end return;

renameFile.cpp

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// **************** Author : Tashin.Parvez *************************\
2+
// **************** Updated: 22-06-23 *************************\
3+
4+
#include <iostream>
5+
#define faster \
6+
ios_base::sync_with_stdio(false); \
7+
cin.tie(0); \
8+
cout.tie(0);
9+
#define CRACKED return 0;
10+
#define nl endl; // NewLine
11+
12+
#define int long long
13+
#define output(x) cout << x << nl // out
14+
#define printarray(arr, len) \
15+
for (int i = 0; i < len; i++) \
16+
{ \
17+
cout << arr[i] << " "; \
18+
if (i + 1 == len) \
19+
cout << endl; \
20+
} // array print
21+
using namespace std;
22+
23+
int32_t main()
24+
{
25+
faster;
26+
string s;
27+
getline(cin, s); // take line
28+
29+
for (int i = 0; i < s.length(); i++)
30+
{
31+
if ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z'))
32+
cout << s[i];
33+
else
34+
cout << '_';
35+
}
36+
cout << '_';
37+
cout << '_';
38+
39+
cout << nl;
40+
41+
CRACKED;
42+
}

0 commit comments

Comments
 (0)