Task: | misa |
Sender: | zxc |
Submission time: | 2016-08-01 15:15:04 +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.06 s | details |
#3 | ACCEPTED | 0.06 s | details |
#4 | ACCEPTED | 0.06 s | details |
#5 | ACCEPTED | 0.06 s | details |
#6 | ACCEPTED | 0.07 s | details |
#7 | ACCEPTED | 0.09 s | details |
Code
#include <bits/stdc++.h> using namespace std; char t[50][50]; int r,s; int f() { int ret = 0; for(int i = 0; i < r; ++i) { for(int j = 0; j < s; ++j) { if(t[i][j] == '.') continue; for(int k = 0; k < 8; ++k) { int ux = i; int uy = j; if(k <= 2) --ux; if(k >= 4 && k <= 6) ++ux; if(k == 0 || k == 7 || k == 6) --uy; if(k >= 2 && k <= 4) ++uy; if(ux >= 0 && ux < r && uy >= 0 && uy < s) { ret += t[ux][uy] == 'o'; } } } } return ret; } int main() { cin>>r>>s; for(int i = 0; i < r; ++i) { for(int j = 0; j < s; ++j) { cin>>t[i][j]; } } int ans = f(); for(int i = 0; i < r; ++i) { for(int j = 0; j < s; ++j) { if(t[i][j] == '.') { t[i][j] = 'o'; ans = max(ans, f()); t[i][j] = '.'; } } } cout<<ans/2<<'\n'; }
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 |