cacophonix's blog

By cacophonix, 10 years ago, In English

You need to include a header file

#include <sys/resource.h>

and in the main() function you need to write these lines

rlimit R;
getrlimit(RLIMIT_STACK, &R);
R.rlim_cur = R.rlim_max;
setrlimit(RLIMIT_STACK, &R);

thanks(not this line).

Full text and comments »

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

By cacophonix, 11 years ago, In English

I cant find the Final scoreboard of tco13 final round. has it been published ?

Full text and comments »

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

By cacophonix, 11 years ago, In English

EDITED:

I want to use a custom compare function written inside a class like this code.

class cl{ 
	public: 
	
	string st; 
	int *pos;
	
	cl(string s){
		st=s; 
		pos=new int[s.size()];
		for (int i = 0; i < (int)s.size(); i++){
			pos[i]=i;
		}
		
	} 
	
	
	static int compare(int c1,int c2 ){
		 return st[c1]<st[c2]; 
	} 
	
	
	void function_using_custom_compare_function(){
		 sort(pos,pos+st.size(),compare); 
	} 
};

but i cant compile this code.

how to use the compare function inside a class ?

Full text and comments »

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

By cacophonix, 11 years ago, In English

for running testcases in vim if first copy the test cases in a text file called 'in' and press F6

which runs the code by taking input from the 'in' text file.

i have

map <F6> :w<CR>:!g++ % -g && (ulimit -c unlimited; ./a.out < in) <CR>

in my .vimrc file.

IS IT POSSIBLE TO RUN THE CODE BY TAKING INPUT FROM THE SYSTEM CLIPBOARD ?

Full text and comments »

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

By cacophonix, 12 years ago, In English

SHANGHAI JIAOTONG Mithril is champion in both Asia Jinhua Regional Contest site and dhaka site .... then why this team is not in world-final ... can anyone explain ?

Full text and comments »

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

By cacophonix, 12 years ago, In English

I have a Bipartite Graph. I want the indeces of vertices that covers all the vertices. Cant't get it. any help .....

Full text and comments »

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

By cacophonix, 12 years ago, In English

these two function calls seem same to me but they gives different outputs.
I tried a lot to understand the problem. but i failed.
Can anybody help please.

code:
sum1==row wise cumulative sum for each column
sum2==column wise cumulative sum for each row

here the fun(n-1,m-1) function call gives correct output.

int fun(int r,int c){
	int t1=0,t2=0;
	if(r==n-1&&c==m-1)return max(sum1[r][c],sum2[r][c]);
	if(r==n||c==m)return 0;
	int &ret=dp[r][c];
	if(ret!=-1)return ret;
	t1=fun(r+1,c)+sum1[r][c];
	t2=fun(r,c+1)+sum2[r][c];
	return ret=max(t1,t2);
}

fun(0,0);//this gives wrong output

int fun(int r,int c){
	int t1=0,t2=0;
	if(r==0&&c==0)return max(sum1[r][c],sum2[r][c]);
	if(r<0||c<0)return 0;
	int &ret=dp[r][c];
	if(ret!=-1)return ret;
	t1=fun(r-1,c)+sum1[r][c];
	t2=fun(r,c-1)+sum2[r][c];
	return ret=max(t1,t2);
}

fun(n-1,m-1);//this gives correct output

Full text and comments »

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

By cacophonix, 12 years ago, In English

From yesterday i noticed that i cannot see other coder's submitted codes. Is there anyone facing this problem?

Full text and comments »

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