Task: | misa |
Sender: | ollpu |
Submission time: | 2016-08-01 15:31:18 +0300 |
Language: | C++ |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.06 s | details |
#2 | ACCEPTED | 0.05 s | details |
#3 | ACCEPTED | 0.05 s | details |
#4 | ACCEPTED | 0.05 s | details |
#5 | ACCEPTED | 0.06 s | details |
#6 | ACCEPTED | 0.06 s | details |
#7 | ACCEPTED | 0.06 s | details |
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 |