thanks brother
I did the exact same thing but still got wrong answer.
https://www.codechef.com/viewsolution/37002865
Can you help me figure out what I missed …
Thank You
Consider the test input:
1
R
0 0
1
100 1
I had wrongly interpreted the instructions, I was taking y1+1 for D instead for U. But after that I still received a TLE, I was using fast i/o and ‘\n’ but still was getting a TLE. After that instead of using an array for storing the character counts I switched to using 4 individual variables and then got accepted. Can anyone explain why I was getting a TLE with an array?
yeah bro thanks man , i got my mistake ! 
I ran my code using custom input same as given in the problem statement and it ran successfully.
But on submitting I was shown that my answer is wrong. Can anyone please help me out in finding out what went wrong in my code??
https://www.codechef.com/viewsolution/37020739
It doesn’t give the required output, though:
[simon@simon-laptop][13:52:51]
[~/devel/hackerrank/otherpeoples]>echo "1
RLUDRLUD
1 2
2
2 3
1 -2" | ./harry_8761-CENS20G.py
YES 2
NO
(note the extra blank line).
Brother I tried to make the changes u suggested …still the same response i.e. “Wrong Answer”
Can you give the link to your new submission?
I got the same error even after using FAST IO, So, i changed the endl with \n and it worked!!
my code blocks ide is not showing output when i am using “\n” but showing output when i am using endl for this problem. But using “\n” gave me correct answer now when submitted ,can anyone help me rectify this.
There are several differences between your two submissions besides the use of "\n" vs endl:
https://www.diffchecker.com/GPBAPoj6
with the most important one being this:
m.count('U')>=l
![]()
Edit: As for Codeblocks - I’m guessing it’s just not doing a final flush(?) A bit weird, but oh well.
Having
cout.flush();
as the last statement executed should do the trick, I guess.
yeah i got the point using map, then it turned tle so i tried using multiset.
yeah this worked out ,thanks for the reply.
It’s pathetic that only for this reason i got tle.
Thank You
#include
#include
#include
#include
#include
#define ll long long
#include
#include
#define fr for(ll i=0;i<n;i++){ cin>>temp; a.push_back(temp);}
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t,l,r,x,y,n,a,b,m,temp;
cin>>t;
while(t–)
{
string s;
cin>>s;
cin>>x>>y;//starting position for each query
ll countr=0,countl=0,countu=0,countd=0;
for(ll i=0;i<s.size();i++)
{
if(s[i]==‘R’)
countr++;
if(s[i]==‘L’)
countl++;
if(s[i]==‘U’)
countu++;
if(s[i]==‘D’)
countd++;
}
cin>>r;
while(r–)
{
ll x1,y1,dr=0,ur=0,lr=0,rr=0;
cin>>x1>>y1;
lr=abs(x-x1);
ur=abs(y-y1);
if(((countl>=lr&&(x>x1))||(countr>=lr&&(x<x1))||lr==0)&&((countu>=ur&&(y1>y))||(countd>=ur&&(y>y1))||ur==0))
{
cout<<“YES”<<" "<<(lr+ur)<<endl;
}
else
{
cout<<“NO”<<endl;
}
}
}
}
plz tell me why i am getting TLE for this…plz help