Code chef Train Partner

//I am struggling
//Just Not Good at it

#include<bits/stdc++.h>

using namespace std;

#define fast ios_base::sync_with_stdio(false)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
#define psb push_back

typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
typedef map<int, int>mpii;
typedef map<int, string>mpsi;

const int mod = 1000007;
const int high = 600;

mpii mp;
mpsi ms;

void partner()
{
    int i , cnt=0;

    for(i=8; i<=high; i+=8)
    {
        mp[i] = i-1;
        ms[i] = "SU";
        mp[i-1] = i;
        ms[i-1] = "SL";
    }

    for(i=1; i<=high; i++)
    {
        if(!mp[i])
        {
            mp[i] = i+3;
            mp[i+3] = i;
            cnt++;
            if(cnt == 1)
            {
                ms[i] = "LB";
                ms[i+3] = "LB";
            }

            else if(cnt == 2)
            {
                ms[i] = "MB";
                ms[i+3] = "MB";
            }

            else if(cnt == 3)
            {
                ms[i] = "UB";
                ms[i+3] = "UB";
            }
        }

        else cnt=0;
    }

//    for(i=1 ,cnt=1 ; i<=1000; i+=8 , cnt++)
//    {
//        cout << cnt << ". " << i << " " << i+7 << "\n";
//    }
}

int main()
{
    fast;
    partner();
    int t , n;
    cin >> t;
    while(t--)
    {
        cin >> n;
        cout << mp[n] << ms[mp[n]] << "\n";
    }

    return 0;
}

Comments

Popular posts from this blog

SPOJ-CMG - Collecting Mango

LightOJ 1009 - Back to Underworld

LeetCode Palindrome Number