Hackerearth: Seating Arrangement (Unsolved)

code that not accepted:

#include<bits/stdc++.h>
int main()
{
    int i,t,rem,n,near=0,flag;
    scanf("%d",&t);
    for(i=0; i<t; i++)
    {
        scanf("%d",&n);
        rem=n%12 ;//block 1;
        switch(rem)
        {
        //window seat
        case 1: //1+12
        case 13:
        case 25:
        case 37:
        case 49:
        case 61:
        case 73:
        case 85:
        case 97:
            flag=0;
            near=n+11;
            break;
        case 6:
        case 18:
        case 42:
        case 54:
        case 66:
        case 78:
        case 90:
        case 102:
            flag=0;
            near=n+1;
            break;
        // for(case=7;case<=108;case=case+12)
        case 7: //7+12 increment
        case 19:
        case 31:
        case 43:
        case 55:
        case 67:
        case 79:
        case 91:
        case 103:
            flag=0;
            near=n-1;
            break;
        case 12:
        case 24:
        case 36:
        case 48:
        case 60:
        case 72:
        case 84:
        case 96:
        case 108:
            flag=0;
            near=n-1;
            break;
        //middle seat
        case 2:
        case 14:
        case 26:
        case 38:
        case 50:
        case 62:
        case 74:
        case 86:
        case 98:
            flag=1;
            near=n+9;
            break;
        case 5:
        case 17:
        case 29:
        case 41:
        case 53:
        case 65:
        case 77:
        case 89:
        case 101:
            flag=1;
            near=n+3;
            break;
        case 8:
        case 20:
        case 32:
        case 44:
        case 56:
        case 68:
        case 80:
        case 92:
        case 104:
            flag=1;
            near=n-3;
            break;
        case 11:
        case 23:
        case 35:
        case 47:
        case 59:
        case 71:
        case 83:
        case 95:
        case 107:
            flag=1;
            near=n-9;
            break;
        //aisle seat
        case 3:
            flag=2;
            near=n+7;
            break;
        case 4:
            flag=2;
            near=n+5;
            break;
        case 10:
            flag=2;
            near=n-7;
            break;
        case 9:
            flag=2;
            near=n-5;
            break;
        }
        if(flag==0)
        {
            printf("%d WS\n",near);
        }
        if(flag==1)
        {
            printf("%d MS\n",near);
        }
        if(flag==2)
        {
            printf("%d AS\n",near);
        }
    }

    return 0;
}

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *