Ubuntu 12.04에서 Eclipse로 android-ndk-r8c 설정을 해두고 진행하고 있었습니다. 분명히 ndk-build할 때 바뀐 부분만 build되어야 하는데 계속 전부 다 rebuild되는 문제가 발생했습니다. 구글링해서 해결법을 찾았습니다.

 $(ANDROID_NDK)/build/core/definitions.mk 파일을 열어 289 라인을 봅니다.

$1: $$(__ndk_file_dir)

 이 부분을 아래와 같이 바꿔줍니다.

$1: | $$(__ndk_file_dir)

 저장하고 다시 ndk-build해보면 이제 제대로 동작합니다~


* 출처

http://stackoverflow.com/questions/13788824/prevent-ndk-build-from-automatically-cleaning-module

'스터디 > 안드로이드' 카테고리의 다른 글

Network :: NetworkOnMainThreadException 해결법  (0) 2012.08.04
AND

* 정보 올림피아드 1889번 문제입니다.

 시간초과 때문에 시간 줄여볼거라고 삽질하다보니 매크로 함수들을 만들었네요.

 풀이 방법은 백트래킹을 썼고, 백트래킹만 쓰니 입력값이 13일 때 시간초과가 떴었습니다. 시간초과는 N / 2만큼만 루프돌아서 나온 경우의 수를 2배시켜 해결했습니다. N이 홀수인 경우는 중간값으로 한번더 순회한 결과로 나온 경우의 수를 더해줬습니다.

#include <stdio.h>
#include <stdlib.h>

#define MAX_N 14

typedef struct _stack
{
	int top;
	int data[MAX_N];
} stack;

int N, result;
stack queens;

#define push(x) queens.data[queens.top++] = x
#define pop() queens.data[--queens.top]
#define peek() queens.data[queens.top - 1]
#define my_abs(x) ( (x) & 0x80000000 ? (~(x) + 1) : (x) )

void backtracking()
{
	if(queens.top^N)
	{
		register int x, i, ok;
		for(x = 1 ; x <= N ; x++)
		{
			ok = 1;
			for(i = 0 ; i < queens.top ; i++)
			{
				if(!(queens.data[i]^x) ||
					!(my_abs(queens.data[i] - x)^my_abs(i - queens.top)))
				{
					ok = 0;
					break;
				}
			}
			if(ok)
			{
				push(x);
				backtracking();
			}
		}
	}
	else
	{
		result++;
	}
	pop();
}

int main()
{
	FILE *fin = fopen("input.txt", "r"), *fout = fopen("output.txt", "w");
	int x;

	fscanf(fin, "%d", &N);

	for(x = 1 ; x <= (N >> 1) ; x++)
	{
		push(x);
		backtracking();
	}
	result *= 2;
	if(N & 1)
	{
		push((N >> 1) + 1);
		backtracking();
	}

	fprintf(fout, "%d", result);

	fclose(fin);
	fclose(fout);

	return 0;
}


'스터디 > 알고리즘' 카테고리의 다른 글

Algorithm :: 치즈  (0) 2012.08.06
Algorithm :: 종이자르기  (0) 2012.08.06
Algorithm :: 저글링 방사능 오염  (0) 2012.08.02
Algorithm :: 해밀턴 순환회로  (0) 2012.08.01
Algorithm :: 3n + 1 문제  (0) 2012.07.23
AND

* 정보 올림피아드 1840번 문제입니다.

 이건 if else가 난무해서 보기 안좋네요..

 시간이 지날 때마다 공기랑 녹는 치즈를 맨 바깥부터 BFS 로 같은 값을 넣었습니다. 공기에 값을 넣고 나선 다시 탐색하게 하고 치즈는 값만 넣게 했습니다. 입력할 때 치즈 개수를 세서, 치즈를 녹일 때마다 카운트해서 종료 조건으로 사용했습니다.

#include <stdio.h>

#define MAX_N 101

typedef struct _point
{
	int x;
	int y;
} point;

typedef struct _queue
{
	int top;
	int bottom;
	point data[MAX_N * MAX_N];
} queue;

int x_size, y_size, cheese_count, melt_count;
int cheese[MAX_N][MAX_N];
queue melt_queue;

void enqueue(int x, int y)
{
	melt_queue.data[melt_queue.bottom].x = x;
	melt_queue.data[melt_queue.bottom].y = y;
	melt_queue.bottom++;
	if(melt_queue.bottom == MAX_N * MAX_N)
	{
		melt_queue.bottom = 0;
	}
}

point dequeue()
{
	point ret = { -1, -1 };
	int next_top = melt_queue.top + 1;
	if(next_top == MAX_N * MAX_N)
	{
		next_top = 0;
	}

	if(next_top != melt_queue.bottom)
	{
		ret = melt_queue.data[next_top];
		melt_queue.top = next_top;
	}
	return ret;
}

int main()
{
	FILE *fin = fopen("input.txt", "r"), *fout = fopen("output.txt", "w");
	int i, j, prev_cheese_count = 0;
	point melt_point;

	fscanf(fin, "%d %d", &y_size, &x_size);
	for(i = 1 ; i <= y_size ; i++)
	{
		for(j = 1 ; j <= x_size ; j++)
		{
			fscanf(fin, "%d", &cheese[i][j]);
			if(cheese[i][j])
			{
				cheese_count++;
			}
		}
	}

	melt_queue.bottom = 1;
	for(i = 1 ; cheese_count > 0 ; i++, melt_count++)
	{
		prev_cheese_count = cheese_count;
		cheese[1][1] = -i;
		enqueue(1, 1);
		while(melt_point = dequeue(), melt_point.x != -1)
		{
			if(melt_point.x > 1 && cheese[melt_point.y][melt_point.x - 1] != -i)
			{
				if(cheese[melt_point.y][melt_point.x - 1] == 1)
				{
					cheese_count--;
				}
				else
				{
					enqueue(melt_point.x - 1, melt_point.y);
				}
				cheese[melt_point.y][melt_point.x - 1] = -i;
			}
			if(melt_point.x < x_size && cheese[melt_point.y][melt_point.x + 1] != -i)
			{
				if(cheese[melt_point.y][melt_point.x + 1] == 1)
				{
					cheese_count--;
				}
				else
				{
					enqueue(melt_point.x + 1, melt_point.y);
				}
				cheese[melt_point.y][melt_point.x + 1] = -i;
			}
			if(melt_point.y > 1 && cheese[melt_point.y - 1][melt_point.x] != -i)
			{
				if(cheese[melt_point.y - 1][melt_point.x] == 1)
				{
					cheese_count--;
				}
				else
				{
					enqueue(melt_point.x, melt_point.y - 1);
				}
				cheese[melt_point.y - 1][melt_point.x] = -i;
			}
			if(melt_point.y < y_size && cheese[melt_point.y + 1][melt_point.x] != -i)
			{
				if(cheese[melt_point.y + 1][melt_point.x] == 1)
				{
					cheese_count--;
				}
				else
				{
					enqueue(melt_point.x, melt_point.y + 1);
				}
				cheese[melt_point.y + 1][melt_point.x] = -i;
			}
		}
	}
	fprintf(fout, "%d\n%d", melt_count, prev_cheese_count);

	fclose(fin);
	fclose(fout);

	return 0;
}


'스터디 > 알고리즘' 카테고리의 다른 글

Algorithm :: N Queen  (0) 2012.08.17
Algorithm :: 종이자르기  (0) 2012.08.06
Algorithm :: 저글링 방사능 오염  (0) 2012.08.02
Algorithm :: 해밀턴 순환회로  (0) 2012.08.01
Algorithm :: 3n + 1 문제  (0) 2012.07.23
AND