HackerEarth Rahuls Logo problem solution YASH PAL, 31 July 2024 In this HackerEarth Rahul’s Logo problem solution Rahul has set upon the quest for a new logo of his company. He has created the following continuous logo: / / / / / / / / / / / / / / / / / / However, his sister, Rashi, likes the following discontinuous design more / / / / / / / / / / / / The size of a logo is the longest continuous streak of the same characters on an arm. So, the size of 1st logo is 5 while that of 2nd one is 4. Now, he wants to paint both of these logos on a canvas. Given an integer N, write a program that outputs these logos for sizes N and N + 1, one below the other. Please note that Rahul’s logo is only valid for odd sizes and Rashi’s logo is only valid for even values. HackerEarth Rahul’s Logo problem solution. #include <bits/stdc++.h>using namespace std;#define MOD 1000000007#define pb(x) push_back(x)#define mp(x,y) make_pair(x,y)#define FF first#define SS second#define s(n) scanf("%d",&n)#define sl(n) scanf("%lld",&n)#define sf(n) scanf("%lf",&n)#define ss(n) scanf("%s",n)#define sc(n) {char temp[4]; ss(temp); n=temp[0];}#define INF (int)1e9#define LINF (long long)1e18#define EPS 1e-9#define maX(a,b) ((a)>(b)?(a):(b))#define miN(a,b) ((a)<(b)?(a):(b))#define abS(x) ((x)<0?-(x):(x))typedef long long ll;typedef unsigned long long LL;typedef pair<int,int> PII;typedef pair<ll,ll> Pll;typedef pair<int,PII> TRI;typedef vector<int> VI;typedef vector<ll> VL;typedef vector<ll> vl;typedef vector<PII> VII;typedef vector<TRI> VT;int n1, n2;char a[1000][1000];void precompute() {}void read() { s(n1); n2 = n1 + 1;}void preprocess() {}void make_diamond(int i, int j, int num) { if(num <= 0) return; int front = j, back = j + 1; int d[] = {-1, 1}, ch[] = {'/','\'}; int cur = 0; int ff = 0, bb = 1, off = 0; while(front < back) { a[i + cur][front + off] = ch[ff]; a[i + cur][back + off] = ch[bb]; if(cur == num - 1) { swap(ff, bb); cur++; off = 2; a[i + cur][front + off] = ch[ff]; a[i + cur][back + off] = ch[bb]; } front += d[ff]; back += d[bb]; cur++; } make_diamond(i + 2, j, num - 2);}void print_logo(int n) { memset(a, 0, sizeof a); int N = 2 * n; make_diamond(0, n - 1, n); for (int i = 0; i < N; ++i) { int p1 = 0, p2 = 0; while(1) { while(p2 < N + 2 and a[i][p2] == 0) p2++; if(p2 == N + 2) break; while(p1 < p2) a[i][p1++] = ' '; p1 = ++p2; } } for (int i = 0; i < N; ++i) { puts(a[i]); }}void solve() { print_logo(n1); print_logo(n2);}int main() { precompute(); read(); preprocess(); solve(); return 0;} Second solution #include<bits/stdc++.h>#define PB push_back#define MP make_pair#define F first#define S second#define SZ(a) (int)(a.size())#define SET(a,b) memset(a,b,sizeof(a))#define LET(x,a) __typeof(a) x(a)#define TR(v,it) for( LET(it,v.begin()) ; it != v.end() ; it++)#define repi(i,n) for(int i=0; i<(int)n;i++)#define si(n) scanf("%d",&n)#define sll(n) scanf("%lld",&n)#define sortv(a) sort(a.begin(),a.end())#define all(a) a.begin(),a.end()#define DRT() int t; cin>>t; while(t--)#define TRACEusing namespace std;#ifdef TRACE#define trace1(x) cerr << #x << ": " << x << endl;#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;#define trace3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;#define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;#define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;#else#define trace1(x)#define trace2(x, y)#define trace3(x, y, z)#define trace4(a, b, c, d)#define trace5(a, b, c, d, e)#define trace6(a, b, c, d, e, f)#endiftypedef long long LL;typedef pair<int,int> PII;typedef vector<int> VI;typedef vector< PII > VPII;void g(int n){ for(int i=0; i<n;i++) { for(int j=0; j<2+i; j++)cout<<" "; for(int j=0; j<n-i; j++) if(j%2==0)cout<<"\"; else cout<<" "; for(int j=n-i; j>0; j--) if(j%2)cout<<"/"; else cout<<" "; cout<<endl; }}void f(int n){ for(int i=0; i<n;i++) { for(int j=1; j < n-i; j++)cout<<" "; for(int j=0; j<i+1; j++) if(j%2==0)cout<<"/"; else cout<<" "; for(int j=0; j<i+1; j++) if((i-j)%2==0)cout<<"\"; else cout<<" "; cout<<endl; }}int main(){ int n; cin>>n; f(n); g(n); n++; f(n); g(n); return 0;} coding problems