parina's blog

By parina, 13 years ago, In English
Getting WA on testcase 8
testcase 8 is
981
1
and the answer is "YES"
my code is given the write answer.But why???

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
#define diff(x,y) x>y ? (x-y):(y-x)
#define i64d unsigned long long



int main(){

int n,j,i,k,t,l,s;
char a[10],b[10],c[10],d[10],e[10],f[10];

scanf("%d %d",&n,&k);
t=n+k;


sprintf(a,"%d",n);
sprintf(b,"%d",k);
sprintf(e,"%d",t);

j=0;
for(i=0;i<strlen(e);i++){
    if(e[i]!='0')
      f[j++]=e[i];
    }

j=0;
for(i=0;i<strlen(a);i++){
    if(a[i]!='0')
      c[j++]=a[i];

    }


j=0;
for(i=0;i<strlen(b);i++){
    if(b[i]!='0')
      d[j++]=b[i];
        }


s=atoi(c);
l=atoi(d);
k=atoi(f);


if(s+l==k)
printf("YES\n");
else
printf("NO\n");

return 0;
}





                   

Full text and comments »

  • Vote: I like it
  • -36
  • Vote: I do not like it

By parina, 13 years ago, In English
I am WA in this problem [http://www.codeforces.com/problemset/problem/71/B]
I don't know why.Please give me some sample input-output Or have a look on my code.

[code]
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
#define diff(x,y) x>y ? (x-y):(y-x)
#define i64d unsigned long long



int main(){

int n,i,k,t,l,c;
int j;

scanf("%d %d %d",&n,&k,&t);
l=((t*n)/100);
j=(t*n)%100;

for(i=l-1;i>=0;i--){
if(i==l-1)
 ;
 else
 printf(" ");
printf("%d",k);
}

printf(" %d",j/10);

for(i=l+1;i<n;i++)
printf(" 0");
printf("\n");


return 0;
}

[/code]

Full text and comments »

  • Vote: I like it
  • -2
  • Vote: I do not like it

By parina, 13 years ago, In English
I have participated in a codeforce's contest for the 1st time last day. I have faced a problem [actually silly 1]. In UVa,we use generally a while loop to confirm the code will be executed for more than 1 testcases.
like
  
[code]
while(scanf("%d",&n)==1){
//code is here
}
[/code]


But in codeforces,
I got TLE,when I removed that part ,and make the code for only one testcase I got Accepted.
[when practice, I got AC with While() also]


Can anyone tell me,when I should use it or not???

thanks in advance.....

Full text and comments »

  • Vote: I like it
  • +4
  • Vote: I do not like it

By parina, 13 years ago, In English
I don't know why I am getting TLE on this problem ,please have a look on this....

////links for code removed after AC

thanks in advance.....

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By parina, 13 years ago, In English
[code]
@echo off
setlocal ENABLEDELAYEDEXPANSION
set s=0
for %%i in (%*) do (
set /A j=%%i/100
start http://uva.onlinejudge.org/external/!j!/%%i.html
set s=1
)
if !s!==1 goto end

echo Give 0 to end.
echo.
:again
set /P x=UVA Problem No.:
if !x! EQU 0 goto end
if !x! LSS 100 (
echo Bad Parameter
goto again
)
if !x! GEQ 1000 (
if !x! LSS 10000 (
echo Bad Parameter
goto again
)
)
set /A y=!x!/100
start http://uva.onlinejudge.org/external/!y!/!x!.html
goto again
:end
[/code]

guys,paste this code on a textfile and save it with uva.bat  
See,searching problems are easier now.

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it

By parina, 13 years ago, In English

[code]

string line;

cin>>line;

char* er = (char*)malloc( sizeof( char ) *(line.length() +1) );

strcpy( er, line.c_str() );

[/code]



Full text and comments »

  • Vote: I like it
  • +2
  • Vote: I do not like it

By parina, 13 years ago, In English

[code]
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <iterator>
#include <utility>
using namespace std;
#define i64 long long
#define sq(a) ((a)*(a))

struct point{
    i64 x,y;
 }p[1000000],p0;


////distance between two points
 i64 dist(const point &a, const point &b) {
    return sq(a.x-b.x) + sq(a.y-b.y);
}



////Area of three points to find left turn or right
i64 xmult(point a,point b,point c)
{
return a.x*(b.y-c.y) + b.x*(c.y-a.y) + c.x*(a.y-b.y);
}



bool cmpp(const point &a,const point &b)
{

/*if area >0 then angleof b > angleof a
area=0 means co-linear
*/
if(xmult(p0,a,b) > 0)
           return true;
else if (xmult(p0,a,b)==0&& dist(p0,a)<dist(p0,b) )
           return true;

return false;
}





bool cmp2(const point &a,const point &b)
{
if(xmult(p0,a,b) > 0)
           return true;
else if (xmult(p0,a,b)==0&& dist(p0,a)<dist(p0,b) )
           return true;

return false;
}




int main(){
long n,i,j,k,t,l,top,ke1,ke;
i64 cx,cy;
char c,d;

point op;

scanf("%ld",&t);
for(l=0;l<t;l++){
scanf("%ld",&n);
j=0;
for(i=0;i<n;i++){
scanf("%lld %lld%c%c",&cx,&cy,&d,&c);
if(c=='Y'){
    p[j].x=cx;    p[j].y=cy;    j++;
    }
}

ke1=0;
op=p[0];
for(i=1;i<j;i++){
if(p[i].x<op.x ||(p[i].x==op.x&&p[i].y<op.y)){
   op=p[i];
    ke1=i;
    }
}

//reference point ,swapping with p[0]
swap(p[0],p[ke1]);


p0=p[0];
sort(p+1,p+j,cmp2);







ke1=0;
op=p[0];

for(i=1;i<j;i++){
if(p[i].x>op.x||(p[i].x==op.x&&p[i].y>op.y)){
   op=p[i];
    ke1=i;
    }
}

p0=p[ke1];
sort(p+ke1,p+j,cmpp);


printf("%ld\n",j);
for(i=0;i<j;i++){
printf("%lld %lld\n",p[i].x,p[i].y);
}
}
return 0;
}
[/code]

I wanna learn more....
[email protected]

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it