Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<iostream>
- #include<set>
- #include<map>
- #include<queue>
- #include<vector>
- #include<string.h>
- #include<algorithm>
- #include <iomanip>
- #define sc scanf
- #define pr printf
- #define fr first
- #define se second
- #define pb push_back
- #define mp make_pair
- using namespace std;
- const int MN = 510;
- const int INF = 10000010;
- const double eps = 1e-12;
- int r, c;
- char s[MN][MN];
- main(){
- freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
- sc("%d%d", &r, &c);
- for(int i=0; i<r; i++){
- sc(" %s", s[i]);
- }
- int mv = 0, ans = 0;
- for(int i=0; i<r; i++){
- for(int j=0; j<c; j++){
- if(s[i][j] == 'o'){
- ans += (s[i][j+1] == 'o') + (s[i+1][j-1] == 'o') + (s[i+1][j] == 'o') + (s[i+1][j+1] == 'o');
- }
- else {
- int cur = (s[i][j-1] == 'o') + (s[i-1][j-1] == 'o') + (s[i-1][j] == 'o') + (s[i-1][j+1] == 'o')
- + (s[i][j+1] == 'o') + (s[i+1][j-1] == 'o') + (s[i+1][j] == 'o') + (s[i+1][j+1] == 'o');
- mv = max(mv, cur);
- }
- }
- }
- pr("%d\n", ans+mv);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment