CSES - Leirikisa 4 - Results
Submission details
Task:misa
Sender:siirikuoppala
Submission time:2016-08-01 15:44:49 +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.05 sdetails
#7ACCEPTED0.05 sdetails

Code

#include <iostream>

using namespace std;

int t[51][51];

int main(){
    int sx[8]={1, 1, 0, -1, -1, -1,  0,  1};
    int sy[8]={0, 1, 1,  1,  0, -1, -1, -1};
    int R,S;
    cin >> R >> S;
    for(int i=0; i<R; ++i){
        for(int j=0; j<S; ++j){
            char a;
            cin >> a;
            if(a=='o') t[i][j]=1;
        }
    }
    int v=0;
    int b=0;
    for(int i=0; i<R; ++i){
        for(int j=0; j<S; ++j){
            if(t[i][j]==1){
                for(int k=0; k<4; ++k){
                    if(j+sx[k]>=0) v+= t[i+sy[k]][j+sx[k]];
                }
            }
            else {
                int c=0;
                for(int k=0; k<8; ++k){
                    if(i+sy[k]>=0 && j+sx[k]>=0 && t[i+sy[k]][j+sx[k]]==1) ++c;
                }
                b=max(b, c);
            }
        }
    }
    cout << v+b;


}

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