CSES - Leirikisa 4 - Results
Submission details
Task:misa
Sender:eXeP
Submission time:2016-08-01 15:17:50 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.06 sdetails
#2ACCEPTED0.05 sdetails
#30.06 sdetails
#40.06 sdetails
#50.05 sdetails
#6ACCEPTED0.05 sdetails
#70.05 sdetails

Code

#include <bits/stdc++.h>

#define i64 long long
#define u64 unsigned long long
#define i32 int
#define u32 unsigned int

#define pii pair<int, int>
#define pll pair<long long, long long>

#define ld long double
#define defmod 1000000007

#define mati64(a,b) vector<vector<i64>>(a, vector<i64>(b, 0));
using namespace std;
int n, m;
string t[55];

i64 cnt(int i, int j){
  int re = 0;
  for(int ii = i-1; ii <= i+1; ++ii){
    for(int jj = j-1; jj <= j+1; ++jj){
      if(ii < 0 || ii >= n || jj < 0 || jj >= m)
	continue;
      if(ii == i && jj == j)
	continue;
      if(t[ii][jj] == 'o')
	re++;
    }
  }
  return re;
}

int main(){
  cin.sync_with_stdio(0);
  cin.tie(0);
  
  cin >> n >> m;
  for(int i = 0; i < n; ++i)
    cin >> t[i];
  i64 all = 0, mm = 0;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      if(t[i][j] == 'o')
	all+=cnt(i, j);
      else
	mm = max(mm, cnt(i, j));
    }
  }
  all/=2;
  cout << all+mm << endl;
  return 0;
}

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:

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

correct output
12

user output
0

Test 4

Verdict:

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

correct output
50

user output
6

Test 5

Verdict:

input
21 11
ooooooooooo
ooooooooooo
ooooooooooo
ooooooooooo
...

correct output
830

user output
833

Test 6

Verdict: ACCEPTED

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

correct output
53

user output
53

Test 7

Verdict:

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

correct output
4248

user output
4200