vee_sharp's blog

By vee_sharp, history, 9 years ago, In English

I am trying to find out the the no of permutations possible for a string that are palindrome.The only way I could think of is finding out the possible permutations and then checking if each one of them is palindrome or not. Is there any better way?

Full text and comments »

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

By vee_sharp, history, 9 years ago, In English

Hello I am trying to solve the question :http://www.spoj.com/problems/PT07Z/ in SPOJ. I have used bfs to find the leaf node and then used bfs again to find the maximum path.I am trying this approach and I don't know what is causing the error. Here is a link to my solution http://ideone.com/QSJzDf.

Full text and comments »

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

By vee_sharp, history, 9 years ago, In English

I was solving maximum quad area in SPOJ. Here is the link http://www.spoj.com/problems/QUADAREA/. It is a pretty simple one based on formula. However when I used the formula in C++ it showed WA. But the same formula and same logic showed acc when i used scanf and printf. Is there something I am missing? Here are the links to the codes: with cin: http://ideone.com/kSPbfU without cin: http://ideone.com/uF0yiK

Full text and comments »

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

By vee_sharp, history, 9 years ago, In English

I am trying to solve the problem RENT on SPOJ. Here is the link http://www.spoj.com/problems/RENT/.I have done it using dynamic programming and binary search. I cant figure out what is wrong with my code.Here is a link to my code : http://ideone.com/UgnBRN . Please Help.

Full text and comments »

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

By vee_sharp, history, 9 years ago, In English

I am trying to solve SPOJ street parade. But i dont know what is wrong in the following code:

#include<iostream>
#include<algorithm>
#include<stack>
#include<cstdio>
using namespace std;
int main(){
	int n,ne,last;
	cin>>n;
	while(n!=0){
		int ar[n];
		last=0;
        stack <int> s;
        for(int i=0;i<n;i++) 
            cin>>ar[i];
		for(int i=0;i<n;i++){
			if(s.top()==(last+1)){
				s.pop();
				last++;
			}
			else if(ar[i]==(last+1))
				last++;
			else if(!s.empty() && s.top()<ar[i]){
				cout<<"no"<<endl;
				continue;
			}
			else
				s.push(ar[i]);
		}
		cout<<"yes"<<endl;
		cin>>n;
	}
	return 0;
}

Full text and comments »

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