matavanga's blog

By matavanga, 13 years ago, In English

i am trying to solve http://www.spoj.pl/problems/BITMAP/ problem.

my code executes fine in my computer but its giving wrong answer while running on SPOJ .

i can not make out for which testcase it is failing.

i approached in this procedure: first i got all the positions of 1's in the graph. then i searched from these points by a dfs in the array to update the ans array,



my code is http://ideone.com/2p8VC

thanks

Full text and comments »

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

By matavanga, 13 years ago, In English

i am trying to solve http://www.spoj.pl/problems/PT07Z/  problem.

i first got the most farthest point from root and then got the farthest point from that point
but i am getting TLE. can you please find the appropriate algorithm for this problem .
thanks




GOT AC!!! 
THANKS ALL.

Full text and comments »

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

By matavanga, 14 years ago, In English
I can not find out the problem in my code anyone please help..


#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <queue>
#include <sstream>
#include <fstream>
using namespace std;
int main ()
{
    int stdnum,l=10000;
   
    string qlt;
  
   
    cin>>stdnum;
    cin>>qlt;
    int ans[stdnum];
   
    ans[0]=1;
    for(int i=0;i<(int)qlt.length();i++)
    {    
        if(qlt[i]=='=')
        ans[i+1]=ans[i];
       
       
        else if(qlt[i]=='R')
        ans[i+1]=ans[i]+1;
       
       
        else if(qlt[i]=='L')
         ans[i+1]=ans[i]-1;       
         }   
           
    for(int i=0;i<stdnum;i++)
            l=min(l,ans[i]);
    if(l<1)
        {
            l=(-1)*l;
               
            for(int i=0;i<stdnum;i++)ans[i]+=l+1;
        }
            for(int i=0;i<stdnum;i++)cout<<ans[i]<<" ";
           
        }
   

Full text and comments »

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