ODEC01-Editorial

PROBLEM LINK:

Practice
Div-2 Contest

Author: [Vivek Kumar Mishra(vkm41101 | CodeChef User Profile for Vivek Kumar Mishra | CodeChef)
Tester: Vivek Kumar Mishra
Editorialist: Harshit Pandey

DIFFICULTY:

CAKEWALK

PREREQUISITES:

None

PROBLEM:

Determination of the Winner at the end.

QUICK EXPLANATION:

Just Print the Last Character in the string.

EXPLANATION:

We can see clearly that the expression we are talking about will have the final Point Scorer will always be the winner. Therefore the answer will Definitely be the last character of the input string, i.e. str[str.size()-1].

SOLUTIONS:

Setter's Solution

#include <bits/stdc++.h>

using namespace std;

#define nln ‘\n’
#define fr(i, l, h, s) for (long long i = l; i < h; i += s)
#define ll long long
const ll M = 998244353;

/===================================================================/
/*
ll intfromstring(string s)
{
int n=s.length();
ll num=0;
fr(i,0,n,1) num=num*10+(s[i]-‘0’);
return num;
}

ll factn(ll n)
{
ll prod=1;
if(n==0) return 1;
fr(i,1,n+1,1)prod*=i;
return prod;
}

ll factlogn(ll lo, ll hi)
{
if(hi-lo==1) return hilo;
if(hi-lo==2) return hi
(hi-1)*(lo);
int mid=(hi+lo)/2;
return factlogn(lo,mid) * factlogn(mid+1,hi);
}

ll binarySearch(ll arr[], ll lo, ll hi, ll x)
{
if(hi-lo>1)
{
ll mid=(lo+hi)/2;
if(arr[mid]==x) return mid;
if(arr[mid] > x) return binarySearch(arr, lo, mid-1, x);
if(arr[mid] < x) return binarySearch(arr, mid+1, hi, x);
}
return -1;
}

ll firstOccurence(ll arr[], ll lo, ll hi, ll x)
{
if (hi - lo > 1)
{
ll mid = (lo + hi) / 2;
if (arr[mid] == x)
return firstOccurence(arr, lo, mid, x);
if (arr[mid] < x)
return firstOccurence(arr, mid + 1, hi, x);
if (arr[mid] > x)
return firstOccurence(arr, lo, mid - 1, x);
}
if (arr[lo] == x)
return lo;
if (arr[hi] == x)
return hi;
return -1;
}

ll lastOccurence(ll arr[], ll lo, ll hi, ll x)
{
if (hi - lo > 1)
{
ll mid = (lo + hi) / 2;
if (arr[mid] == x)
return lastOccurence(arr, mid, hi, x);
if (arr[mid] < x)
return lastOccurence(arr, mid + 1, hi, x);
if (arr[mid] > x)
return lastOccurence(arr, lo, mid - 1, x);
}
if (arr[hi] == x)
return hi;
if (arr[lo] == x)
return lo;
return -1;
}

ll count(ll arr[], ll n, ll x)
{
return lastOccurence(arr, 0, n - 1, x) - firstOccurence(arr, 0, n - 1, x) + 1;
}

long long int maxl(long long int a, long long int b)
{
if (a > b)
return a;
return b;
}

long long int minl(long long int a, long long int b)
{
if (a < b) return a;
return b;
}

long long int absl(long long int a)
{
if(a<0)return -a;
return a;
}
/
/
====================================================================*/

void testCase()
{
string s;
cin >> s;
cout<<s[s.size()-1]<<nln;
return;
}

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen(“input.txt”, “r”, stdin);
freopen(“output.txt”, “w”, stdout);
#endif
int t = 1;
cin >> t;
while (t–)
{
testCase();
}
return 0;
}