-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP141PROB.cpp
More file actions
91 lines (84 loc) · 1.77 KB
/
P141PROB.cpp
File metadata and controls
91 lines (84 loc) · 1.77 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include<bits/stdc++.h>
using namespace std;
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Ford(i, a, b) for(int i = a; i >= b; i--)
#define ll long long
#define here cout<<"I am here"<<endl;
const int base = 1e9 + 7;
const int maxn = 1000000;
stack <int> Row, Col;
struct VT{
string vt;
};
int main(void){
ios::sync_with_stdio(false);
VT s[100];
int R, C, tmp = 0, res = 0;
int maxs = 0;
cin>>R>>C;
For(i, 1, R){
cin>>s[i].vt;
}
For(i, 1, R){
For(j, 0, s[i].vt.length() - 1){
if(s[i].vt[j] == '.'){
Row.push(i);
Col.push(j);
tmp++;
}
if(s[i].vt[j] == 'o'){
if(j < C-1){
if(s[i].vt[j+1] == 'o') res++;
if(i < R){
if(s[i+1].vt[j] == 'o') res++;
if(s[i+1].vt[j+1] == 'o') res++;
if(j > 0){
if(s[i+1].vt[j-1] == 'o') res++;
}
}
}
if(j == C-1){
if(i < R){
if(s[i+1].vt[j] == 'o') res++;
if(s[i+1].vt[j-1] == 'o') res++;
}
}
}
}
}
if(tmp == 0) cout<<res;
else{
while(Row.empty() == false){
int res = 0;
s[Row.top()].vt[Col.top()] = 'o';
For(i, 1, R){
For(j, 0, s[i].vt.length() - 1){
if(s[i].vt[j] == 'o'){
if(j < C-1){
if(s[i].vt[j+1] == 'o') res++;
if(i < R){
if(s[i+1].vt[j] == 'o') res++;
if(s[i+1].vt[j+1] == 'o') res++;
if(j > 0){
if(s[i+1].vt[j-1] == 'o') res++;
}
}
}
if(j == C-1){
if(i < R){
if(s[i+1].vt[j] == 'o') res++;
if(s[i+1].vt[j-1] == 'o') res++;
}
}
}
}
}
if(res > maxs) maxs = res;
s[Row.top()].vt[Col.top()] = '.';
Row.pop();
Col.pop();
}
cout<<maxs;
}
return 0;
}