thebeginner123's blog

By thebeginner123, 9 years ago, In English

http://codeforces.com/contest/540/problem/C my submission-11373394

Getting TLE everytime om 14th one in this i am first checking that whether destination is reachable from source.then if destination is intact we look for sorroundings tiles if there is any one intact tiles then we switch to that position and then return back to destination

Full text and comments »

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

By thebeginner123, 9 years ago, In English

anwer link-"http://ideone.com/e.js/5jUAHu" type="text/javascript"

problem link-http://www.spoj.com/problems/LINEUP/

using (dp+bitmask) getting WA in masking i am using set of positions

Full text and comments »

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

By thebeginner123, 9 years ago, In English

problem link-http://www.spoj.com/problems/PARADOX/

answer link-"http://ideone.com/e.js/1qv18R" type="text/javascript" >

LOGIC i applied-if there is cycle consisting of odd number of false then paradox otherwise not.

Full text and comments »

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

By thebeginner123, 9 years ago, In English

answer link-"http://ideone.com/e.js/6dB3rw"

problem link-http://www.spoj.com/problems/ABA12C/ getting tle.plssssssssss help stuck since a long time

Full text and comments »

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

By thebeginner123, 9 years ago, In English

DEVUCLASS MARCH CODECHEF http://www.codechef.com/MARCH15/problems/DEVCLASS getting runtime error (when b1==g1)

Your code here...
Y#include<iostream>
#include<cmath>
#include<vector>
#include<cstring>
#include<cstdio>
using namespace std;
typedef vector <int> vec;
int type;
//int v1[100001],v2[100001];
vec v1,v2;
char s[100004];
char s1[100004];

int edit(char c1)
{  int i;
long long sum;
v1.clear();
v2.clear();
sum=0;
//cout<<s<<endl;
//cout<<s1<<endl;
if(c1=='B')
{for(i=0;i<strlen(s);i++)
if(i%2==0&&s[i]!='B')
    v1.push_back(i);
if(i%2==1&&s[i]!='G')
v2.push_back(i);}

if(c1=='G')
{for(i=0;i<strlen(s);i++)
if(i%2==0&&s[i]!='G')
    v2.push_back(i);
if(i%2==1&&s[i]!='B')
v1.push_back(i);}




for(i=0;i<v1.size();i++)
{  long long p=(v1[i]-v2[i]);
if(p<0)
    p=-p;
    sum=sum+pow(p,type);
}
return sum;

}

int  main()
{int t,i;
int b1;
long long g1,g2;
long long b,g;
char c;

scanf("%d",&t);
while(t--)
{scanf("%d",&type);
s1[0]='\0';
s[0]='\0';
//s.clear();
//s1.clear();
//v1.clear();
//v2.clear();
cin>>s;
//cout<<strlen(s)<<endl;
b1=0;
g1=0;
for(i=0;i<strlen(s);i++)
{if(s[i]=='B')
b1++;
else
g1++;}
//cout<<g1<<b1<<endl;
//cout<<abs(g1-b1)<<endl;
if((g1-b1)>1||(g1-b1)<-1)
    {
        printf("-1");
        continue;

    }
    else if(g1==(b1+1))
    {c='G';
    g=edit(c);

    }
     else if(b1==(g1+1))
        {

                c='B';
            g=edit(c);
        }
     else if(b1==g1)
        {


     int  x=edit((char)'B');
     int  y=edit((char)'G');




           g=min(x,y);

     }

    printf("%lld",g);
}
}Your code here...

~~~~~

Full text and comments »

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