Help in past coding round question

This post was flagged by the community and is temporarily hidden.

@smol_brain guy using his big brain to pass Coding Rounds.

bro its past coding round didn’t you see topic.

Can you specify when the pic was taken?

Hello smol_brain
I solved two question i.e. 4 and 5 in this monocept long challenge.
I am sharing you code for both of them the logic is correct but not able to get the output in time limit.
if you can reduce the time then please help.

Find A, B, C:
#include <bits/stdc++.h>
using namespace std;

int main() {
// your code goes here
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while (t–){
long int n,x,k,p=0;
cin>>n;
long int a[n+1];
for(int i=0;i<=n;i++){
cin>>a[i];
}
x=a[0];
vector v1;
vector v2;
vector v3;
if(x<=n){
for(int i=0; i<=x; i++){
for(int j=0; j<=x-i; j++){
k=x-i-j;
if(i<=n && j<=n && k<=n){
v1.push_back(i);
v2.push_back(j);
v3.push_back(k);
}
}
}
for(int i=0; i<v1.size(); i++){
long int count=0,result=0;
for(int m=1; m<=n; m++){
result=(v1[i]^m)+(v2[i]^m)+(v3[i]^m);
if(result==a[m]){
count++;
}
else break;
}
if(count==n && v1[i]<=n && v2[i]<=n && v3[i]<=n){
cout<<v1[i]<<" “<<v2[i]<<” "<<v3[i]<<endl;
p=1;
break;
}
}
//if(p==1) break;
}
if(n<x){
for(int i=0; i<=n; i++){
for(int j=0; j<=n; j++){
k=x-i-j;
if(i<=n && j<=n && k<=n){
v1.push_back(i);
v2.push_back(j);
v3.push_back(k);
}
}
}

        for(int i=0; i<v1.size(); i++){
            long int count=0,result=0;
            for(int m=1; m<=n; m++){
                result=(v1[i]^m)+(v2[i]^m)+(v3[i]^m);
                if(result==a[m]){
                    count++;
                } 
                else break;
            }
            if(count==n && v1[i]<=n && v2[i]<=n && v3[i]<=n){
            cout<<v1[i]<<" "<<v2[i]<<" "<<v3[i]<<endl;
            p=1;
            break;
            } 
        }
        //if(p==1) break;
    }
    
}
return 0;

}

Largest Square in the garden:

#include <bits/stdc++.h>
using namespace std;

int main() {
// your code goes here
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long int n;
cin>>n;
long int a[n],b[n],c[n];
for(int i=0; i<n; i++){
cin>>a[i]>>b[i];
c[i]=b[i]-a[i]+1;
}
long int result=0;
for(int i=0; i<n; i++){
if(c[i]>=result){
long int p=0,q=n,length=0,count=0;
for(int j=i; j<n; j++){
count++;
p=max(p,a[j]);
q=min(q,b[j]);
length=q-p+1;
if(count<=length){
result=max(result,count);
}
else{
break;
}
}
}
else{
continue;
}
}
cout<<result<<endl;
return 0;
}