wrong answer due to fast io

for input i have used fast IO using register…but i am getting a wrong answer,but if i use scanf the code is accepted…
its for the first time i am getting wa for input…i am not getting the logic behind this…

for this question i am getting a WA.

question link

NOTE : sf is for scanf in this code -_-

my code :-

#include<cstdio>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define getcx getchar_unlocked
int sf()

{

register int c = getcx();
	int num = 0;
 
	for(; c < '0' || c > '9'; c = getcx());
 
	for(; c >= '0' && c <= '9'; c = getcx())
		num = (num << 3) + (num << 1) + c - 48;
 
	return num;
 }

int main()

{

int t;

t = sf();

while(t--)

{

		int r;
		r = sf();
		int ax,ay,bx,by,cx,cy;
		ax = sf();
		ay = sf();
		bx = sf();
		by = sf();
		cx = sf();
		cy = sf();
		//scanf("%d%d%d%d%d%d%d",&r,&ax,&ay,&bx,&by,&cx,&cy);
		r*=r;
		int ab,bc,ac;
		ab = (ax-bx)*(ax-bx)+(ay-by)*(ay-by);
		bc = (bx-cx)*(bx-cx)+(by-cy)*(by-cy);
		ac = (ax-cx)*(ax-cx)+(ay-cy)*(ay-cy);
		int count = 0;
		if(ab<=r)
		count++;
		if(bc<=r)
		count++;
		if(count<2)
		if(ac<=r)
		count++;
		if(count>1)
		printf("yes\n");
		else
		printf("no\n");
	}
	return(0);
}
3 Likes

your fast io doesnt handle -ve numbers!!!

UPDATE:-

int scan_d()    
{
    int ip=getchar_unlocked(),ret=0,flag=1;
    for(;ip<'0'||ip>'9';ip=getchar_unlocked())
        if(ip=='-')
        {
            flag=-1;
            ip=getchar_unlocked();
            break;
        }
    for(;ip>='0'&&ip<='9';ip=getchar_unlocked())
        ret=ret*10+ip-'0';
    return flag*ret;
}
2 Likes

is there any other method for fast IO…for negative numbers…

3 Likes

can this one be used for fast io of negative numebers…??

int sf()

{

int cc = getc(stdin);
for (;cc < '0' || cc > '9';)
        cc = getc(stdin);
int ret = 0;
for (;cc >= '0' && cc <= '9';)
{
        ret = ret * 10 + cc - '0';
        cc = getc(stdin);
}
return ret;

}

3 Likes

updating above ans…

1 Like