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

Code

#include <iostream>
using namespace std;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int r, s;
	cin >> r >> s;
	bool t[r][s];
	for (int i = 0; i < r; ++i) {
		for (int j = 0; j < s; ++j) {
			char c;
			cin >> c;
			t[i][j] = c == 'o';
		}
	}
	int m = 0;
	for (int i = 0; i < r; ++i) {
		for (int j = 0; j < s; ++j) {
			if (t[i][j]) continue;
			int v = 0;
			static int pos[8][2] = { {-1, -1}, {-1, 0}, {-1, 1}, {0, 1}, {1, 1}, {1, 0}, {1, -1}, {0, -1} };
			for (int z = 0; z < 8; ++z) {
				int x = i+pos[z][0], y = j+pos[z][1];
				if (x >= 0 && x < r && y >= 0 && y < s) {
					v += t[x][y];
				}
			}
			m = max(m, v);
		}
	}
	for (int i = 0; i < r; ++i) {
		for (int j = 0; j < s; ++j) {
			if (!t[i][j]) continue;
			static int pos[4][2] = { {-1, -1}, {-1, 0}, {-1, 1}, {0, 1} };
			for (int z = 0; z < 4; ++z) {
				int x = i+pos[z][0], y = j+pos[z][1];
				if (x >= 0 && x < r && y >= 0 && y < s) {
					m += t[x][y];
				} 
			}
		}
	}
	cout << m;
}

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