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

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