forked from 18-RAJAT/ONLINE-JUDGE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
A_Not_Shading.cpp
72 lines (70 loc) · 1.51 KB
/
A_Not_Shading.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
#include<bits/stdc++.h>
#define Rajat_Joshi main;
#define CSE ios_base::sync_with_stdio(false);
#define Joshi cin.tie(NULL);
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
#define read(type) readInt<type>()
#define ll long long
#define nL
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define a first
#define b second
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define umap unordered_map
#define uset unordered_set
#define MOD 1000000007
#define imax INT_MAX
#define imin INT_MIN
#define exp 1e9
#define sz(x) (int((x).size()))
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int ttt; cin >> ttt;
while(ttt--) {
//_______________________________________________________//
Rajat_Joshi CSE;
ll n,m,r,c;
cin>>n>>m>>r>>c;
ll answer=-1;
for(int i=0;i<n;++i)
{
for(int j=0;j<m;++j)
{
char ch;cin>>ch;
if(c and ch=='B' and i+1==r and j+1==c){answer=0;}
else if(ch=='B' and (i+1==r or j+1==c)and answer!=0){answer=1;}
else if(ch=='B' and (answer!=0 and answer!=1)){answer=2;}
}
}
cout<<answer<<"\n";
}
return 0;
}