#include <stdio.h>
#include <stdlib.h>

int main() {
    int x[5][1000],y[5];
    int a,b=0,c=0,d=0;
    scanf("%d",&a);
    for(int i=0;i<a;i++)
    {
        for(int j=0;j<5;j++)
        {
            scanf("%1d",&x[j][i]);
            if(x[j][i]==4)
            x[j][i]=11;
            if(x[j][i]==5)
            x[j][i]=12;
            if(x[j][i]==6)
            x[j][i]=13;
            if(x[j][i]==7)
            x[j][i]=21;
            if(x[j][i]==8)
            x[j][i]=22;
            if(x[j][i]==9)
            x[j][i]=23;
            if(x[j][i]==0)
            x[j][i]=32;
        }
    }
    for(int i=0;i<5;i++)
    {
        scanf("%1d",&y[i]);
            if(y[i]==4)
            y[i]=11;
            if(y[i]==5)
            y[i]=12;
            if(y[i]==6)
            y[i]=13;
            if(y[i]==7)
            y[i]=21;
            if(y[i]==8)
            y[i]=22;
            if(y[i]==9)
            y[i]=23;
            if(y[i]==0)
            y[i]=32;
    }
    for(int i=0;i<a;i++)
    {
        for(int j=0;j<5;j++)
        {
            if(y[j]==x[j][i])
            b++;
            else if(abs(y[j]-10)==x[j][i] || y[j]+10==x[j][i])
            {
                c++;
                b++;
                if(c>1)
                break;
            }
            else if(abs(y[i]-1)==x[j][i] || y[i]+1==x[j][i])
            {
                c++;
                b++;
                if(c>1)
                break;
            }
        }
        if(b==5)
        {
            printf("OPEN");
            d++;
            break;
        }
        b=0,c=0;
    }
    if(d==0)
    {
        printf("CLOSE");
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: