I am receiving a runtime error in this code and I am not able to understand the reason.Can anyone help me out and could tell me the reason and the type of runtime error i am getting? I have been solving this question from codeforces,so here i am attaching the link of that submission so that you could see the actual test case in which i am getting this error.Here's the link https://codeforces.com/contest/1294/submission/113416390 .And here's the code
#include <bits/stdc++.h> // Include every standard library
//#include <boost/math/common_factor.hpp>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
bool cmp(pair<int,int>&p1,pair<int,int>&p2)
{
return (p1.first<=p2.first);
}
bool cmpp(pair<int,int>&p1,pair<int,int>&p2)
{
return (p1.second<p2.second);
}
int main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int t;
cin >> t;
while (t--)
{
int n;
cin>>n;
string s;
int x{},y{};
int arr[n],brr[n];
vector<pair<int,int>>vec;
for(int i=0;i<n;i++)
{
cin>>arr[i]>>brr[i];
vec.push_back({arr[i],brr[i]});
}
sort(vec.begin(),vec.end(),cmp);
if(!is_sorted(vec.begin(),vec.end(),cmpp))
cout<<"NO"<<endl;
else
{
cout<<"YES"<<endl;
sort(arr,arr+n);
sort(brr,brr+n);
for(int i=0;i<n;i++)
{
if(arr[i]!=x)
s.append((arr[i]-x),'R');
if(brr[i]!=y)
s.append((brr[i]-y),'U');
x=arr[i];
y=brr[i];
}
cout<<s<<endl;
}
}
return 0;
}