알고리즘/백준(131)
-
[백준 1269번] 대칭 차집합
소스코드123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657#include using namespace std; int na, nb, a[200001], b[200001], tmp[200001], r=0; void merge(int arr[], int start, int mid, int end) { int lidx = start, tmpidx = 0, ridx = mid + 1; while (lidx b[i]; merge_sort(a, 0, na - 1); merge_sort(b, 0, nb - 1); int aidx=0, bidx=0; while (aidx
2017.08.23 -
[백준 1068번] 트리
소스코드1234567891011121314151617181920212223242526272829303132333435363738394041424344#include using namespace std; int n, rm, tr[51][51] = { 0, }, visit[51][51] = { 0, }, root[51] = {0,};int q[10001], h = 0, t = 0, cnt=0; void bfs() { while (h != t) { int cur = q[h++]; int flag = 0; for (int i = 0; i > n; for (int i = 0; i > in; if (in == -1) { q[t++] = i; root[i] = 1; continue; } tr[in][i] = 1; }..
2017.08.21 -
[백준 2688번] 줄어들지 않아
소스코드12345678910111213141516171819202122232425262728293031#include using namespace std; int main() { int tc; cin >> tc; while (tc>0) { long long dp[65][11], n; cin >> n; if (n == 1) { cout
2017.08.21 -
[백준 1890번] 점프
소스코드1234567891011121314151617181920212223242526272829303132333435#include using namespace std; int main() { long long n, board[101][101], cnt[101][101]; cin >> n; for (int i = 0; i board[i][j]; cnt[i][j] = 0; } } // 시작 지점 cnt[0][0] = 1; // 첫째라인부터 마지막라인까지 카운트 for (int i = 0; i
2017.08.15 -
[백준 4883번] 삼각 그래프
소스코드1234567891011121314151617181920212223242526272829303132#include using namespace std; int Min(int a, int b) { return a > b ? b : a;} int main() { int n, dp[100001][3], tc = 1; while (1) { cin >> n; if (!n) break; for (int i = 0; i dp[i][j]; } } dp[1][0] = dp[1][0]+dp[0][1]; dp[1][1] = Min(dp[1][1]+dp[1][0],Min(dp[0][1]+dp[0][2]+dp[1][1], dp[1][1]+dp[0][1])); dp[1][2] = Min(dp[1][1]+dp[1][2], ..
2017.08.15 -
[백준 1057번] 토너먼트
소스코드1234567891011121314#include using namespace std; int main() { int N,a,b,cnt=0; cin >> N >> a >> b; while (a != b) { a = a / 2 + a % 2; b = b/2+b%2; cnt++; } cout
2017.08.14