abdukodir

COCI 2013/2014 Task MISA

Nov 19th, 2013
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<iostream>
  3. #include<set>
  4. #include<map>
  5. #include<queue>
  6. #include<vector>
  7. #include<string.h>
  8. #include<algorithm>
  9. #include <iomanip>
  10.  
  11. #define sc scanf
  12. #define pr printf
  13. #define fr first
  14. #define se second
  15. #define pb push_back
  16. #define mp make_pair
  17. using namespace std;
  18. const int MN = 510;
  19. const int INF = 10000010;
  20. const double eps = 1e-12;
  21.  
  22. int r, c;
  23. char s[MN][MN];
  24.  
  25. main(){
  26. freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
  27. sc("%d%d", &r, &c);
  28. for(int i=0; i<r; i++){
  29. sc(" %s", s[i]);
  30. }
  31. int mv = 0, ans = 0;
  32. for(int i=0; i<r; i++){
  33. for(int j=0; j<c; j++){
  34. if(s[i][j] == 'o'){
  35. ans += (s[i][j+1] == 'o') + (s[i+1][j-1] == 'o') + (s[i+1][j] == 'o') + (s[i+1][j+1] == 'o');
  36. }
  37. else {
  38. int cur = (s[i][j-1] == 'o') + (s[i-1][j-1] == 'o') + (s[i-1][j] == 'o') + (s[i-1][j+1] == 'o')
  39. + (s[i][j+1] == 'o') + (s[i+1][j-1] == 'o') + (s[i+1][j] == 'o') + (s[i+1][j+1] == 'o');
  40. mv = max(mv, cur);
  41. }
  42. }
  43. }
  44. pr("%d\n", ans+mv);
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment