Editorial for Паркиране


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.
by: maya

Тестовете можете да видите тук.

Примерно решение на C++:

#include <iostream>
#include <string>
using namespace std;
int b0=0,b1=0,b2=0,b3=0,b4=0;
void nameri(string s)
{
    int br=0;
    if (s.find('#')!=-1) return;
    for ( int i=0; i<4 ;i++) 
       if (s[i]=='X')
         br++;

    if (br==0)
        b0++;
    else if (br==1)
        b1++;
    else if (br==2)
        b2++;
    else if (br==3) 
        b3++;
    else 
        b4++;
}

int main()
{

    char a[100][100];
    int m,n;
    cin>>n>>m;
    for (int i=0; i<n; i++)
        for (int j=0; j<m; j++) cin>>a[i][j];

    for (int i=0; i<n-1; i++)
        for (int j=0; j<m-1; j++)
        {
            string s="";
            s=s+(char)a[i][j]+(char)a[i][j+1]+(char)a[i+1][j]+(char)a[i+1][j+1];
            nameri(s);
        }
    cout<<b0<<endl<<b1<<endl<<b2<<endl<<b3<<endl<<b4<<endl;
    return 0;
}

Comments

There are no comments at the moment.