# OTSERC - IUPC Editorial

IUPC-Plinth’20 : https://www.codechef.com/PLIN2020/problems/OTSERC

Author: Stephen Vincent

Tester: Priyam Khandelwal

Editorialist: Stephen Vincent

DIFFICULTY: Cakewalk

PREREQUISITES: Basic Math

PROBLEM:

Given a specific arrangement of seat numbers and their color scheme, you have to find the seat number and color of the seat right across the given seat number.

EXPLANATION:

This problem was all about observations, and simple formulations based on them.

If you group rows in groups of two, you can observe that for each group, the seats that are right across (facing each other) have constant sum, G.S. = 12*(2*(group number) + 1) + 1.

Hence, the desired seat number can be obtained by G.S. - N. Let this be the answer.

As for finding the color, you can observe a pattern, and create cases accordingly:

If ans\%6 = \{1, 0\}, the seat is Blue.

If ans\%6 = \{2, 5\}, the seat is Yellow.

If ans\%6 = \{3, 4\}, the seat is Red.

Alternatively, you can create an array of strings color[] = {“Blue”, “Yellow”, “Red”} and print color[min((ans-1)\%6, 5-(ans-1)\%6)]. You can simulate for each seat to understand why this works.

SOLUTION:

Setter's Solution
``````#include <bits/stdc++.h>
using namespace std;

int main()
{
int t;
cin >> t;

string color[] = {"Blue", "Yellow", "Red"};

while(t--)
{
long long n;
cin >> n;

long long sum = (2*((n-1)/12) + 1)*12 + 1;
long long ans = sum-n;

cout << ans << endl;

ans--;
cout << color[min(ans%6, 5-ans%6)] << endl;
}
}
``````