CSES - COCI 2007/2008 #1 - Results
Submission details
Task:Peg
Sender:henrikaalto
Submission time:2019-07-29 13:58:08 +0300
Language:C++ (C++17)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#2ACCEPTED0.01 sdetails
#3ACCEPTED0.01 sdetails
#4ACCEPTED0.01 sdetails
#5ACCEPTED0.01 sdetails
#6ACCEPTED0.01 sdetails

Code

#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
using ii=long long;


char v[15][15];

int main()
{
    const int N = 7;
    for (int i = 1; i <= N; ++i) {
        string s;
        getline(cin, s);
        for(int j = 1; j <= N; ++j) {
            v[i][j] = s[j - 1];
        }
    }
    for (int i = 1; i <= N; ++i) {
        for(int j = 1; j <= N; ++j) {
            //cout << v[i][j];
        }
        //cout << "\n";
    }
    int r = 0;
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= N; ++j) {
            if (v[i][j] != 'o') continue;
            //cout << i << ", " << j << "\n";
            if (v[i + 2][j] == '.' && v[i + 1][j] == 'o') {
                //cout <<"up\n";
                ++r;
            }
            if (i > 2 && v[i - 2][j] == '.' && v[i - 1][j] == 'o') {
                //cout <<"down\n";
                ++r;
            }
            if (v[i][j + 2] == '.' && v[i][j + 1] == 'o') {
                //cout <<"right\n";
                ++r;
            }
            if (j > 2 && v[i][j - 2] == '.' && v[i][j - 1] == 'o') {
                //cout <<"left\n";
                ++r;
            }
        }
    }
    cout << r << "\n";
}

Test details

Test 1

Verdict: ACCEPTED

input
  o.o  
  .o.  
o.ooo.o
.oo.oo.
o.ooo.o
...

correct output
16

user output
16

Test 2

Verdict: ACCEPTED

input
  ...  
  o.o  
.ooooo.
..o.o..
.ooooo.
...

correct output
8

user output
8

Test 3

Verdict: ACCEPTED

input
  oo.  
  .oo  
.oo.oo.
o.oo.oo
oo.oo.o
...

correct output
26

user output
26

Test 4

Verdict: ACCEPTED

input
  ...  
  ..o  
.......
.......
.......
...

correct output
0

user output
0

Test 5

Verdict: ACCEPTED

input
  o.o  
  oo.  
o...o..
oo.o..o
.oo.oo.
...

correct output
13

user output
13

Test 6

Verdict: ACCEPTED

input
  .oo  
  .oo  
oo.o.oo
o......
oo.oo.o
...

correct output
11

user output
11