Task: | misa |
Sender: | eXeP |
Submission time: | 2016-08-01 15:19:35 +0300 |
Language: | C++ |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.05 s | details |
#2 | ACCEPTED | 0.05 s | details |
#3 | ACCEPTED | 0.06 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 <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 < m; ++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: 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 |