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

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

Hi i am trying to solve this problem.. http://community.topcoder.com/stat?c=problem_statement&pm=1215&rd=4555

my code is :

public static int  ColorMe(int i,int j,char color) {
		int ti = i,tj = j;
		if(i>j || i>count || j>count){
			return 0;
		}
	        if(m[i][j]<infy ) return m[i][j];
		if(i==j) {
			m[i][i] =  color==arr[i]?0:1;
			return m[i][i];
		}
		for(int t=i;t<=j&&i<j;t++) {
			if(color == arr[i]){
				i++;//to get the next stripe not in proper color
			}
			if(color == arr[j]){
				
				j--;//to get the next stripe not in proper color
			}
		}
		for(int k=i;k<=j;k++) {
			m[ti][tj] = min(m[ti][tj],ColorMe(i,k, arr[i]) + 1+ (k==j?0: (ColorMe(k+1,j,color))));
		}
		return m[ti][tj];
		
	}

I am getting wrong answer for the last test case.. Please point out what is wrong in it. ColorMe(i,j,col): stripes i to j are in having color = col.

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

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

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

Hi i want to solve this problem using Dynamic programming. Please provide some hint Problem: http://topcoder.bgcoder.com/print.php?id=596

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

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

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

How many unique cycles of length 4 present in a complete Undirected graph of 6 vertices? My answer is 45 and i think its not correct because there are only 4 options 1)15 2)30 3)90 4)360 please share your view

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

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

Автор mufasa, 13 лет назад, По-английски
Can anybody suggest me optimal substructure for the above problem.

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

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

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

Want to factorize 15 digit number.I have implemented the fermat's thm but it is not suitable for numbers having factor not close to square root of that number .Suggest me some methods .Thanx

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

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