CSES - Leirikisa 4 - Results
Submission details
Task:misa
Sender:Kuha
Submission time:2016-08-01 15:15:55 +0300
Language:C++
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.06 sdetails
#2ACCEPTED0.07 sdetails
#3ACCEPTED0.05 sdetails
#4ACCEPTED0.06 sdetails
#5ACCEPTED0.05 sdetails
#6ACCEPTED0.05 sdetails
#7ACCEPTED0.06 sdetails

Code

#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define LINF 999999999999999999LL
#define N (1<<17)
#define M 1000000007

using namespace std;

char c[60][60];

int main () {
  int n, m;
  cin>>n>>m;
  for (int y = 0; y < 60; y++) for (int x = 0; x < 60; x++) c[y][x] = '.';
  for (int y = 1; y <= n; y++) {
    for (int x = 1; x <= m; x++) {
      cin>>c[y][x];
    }
  }
  int by = 1, bx = 1;
  int bn = 0;
  for (int y = 1; y <= n; y++) {
    for (int x = 1; x <= m; x++) {
      if (c[y][x] =='.') {
	int a = 0;
	for (int y1 = y - 1; y1 <= y + 1; y1++) {
	  for (int x1 = x - 1; x1 <= x + 1; x1++) a += c[y1][x1] == 'o';
	}
	if (bn < a) by = y, bx = x, bn = a;
      }
    }
  }
  c[by][bx] = 'o';
  int ans = 0;
  for (int y = 1; y <= n; y++) {
    for (int x = 1; x <= m; x++) {
      if (c[y][x] == 'o') {
	for (int y1 = y - 1; y1 <= y + 1; y1++) {
	  for (int x1 = x - 1; x1 <= x + 1; x1++) if (y1 != y || x1 != x) ans += c[y1][x1] == 'o';
	}
      }
    }
  }
  cout<<ans / 2<<endl;
}

Test details

Test 1

Verdict: ACCEPTED

input
2 3
..o
o..

correct output
2

user output
2

Test 2

Verdict: ACCEPTED

input
2 2
oo
oo

correct output
6

user output
6

Test 3

Verdict: ACCEPTED

input
1 23
o..oo.ooooo..o.oooo.ooo

correct output
12

user output
12

Test 4

Verdict: ACCEPTED

input
2 20
..oooooo.oo.....o.oo
ooooooooo.o.ooo..ooo

correct output
50

user output
50

Test 5

Verdict: ACCEPTED

input
21 11
ooooooooooo
ooooooooooo
ooooooooooo
ooooooooooo
...

correct output
830

user output
830

Test 6

Verdict: ACCEPTED

input
28 8
........
.oo..oo.
..oo....
..o.o...
...

correct output
53

user output
53

Test 7

Verdict: ACCEPTED

input
49 50
ooo....oooo.oooo...o..o.oooooo...

correct output
4248

user output
4248