Блог пользователя matavanga

Автор matavanga, 12 лет назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор matavanga, 13 лет назад, По-английски

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.

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор matavanga, 13 лет назад, По-английски
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]<<" ";
           
        }
   

Полный текст и комментарии »

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится