[C++] 백준 1932 정수 삼각형
·
Algorithm/Baekjoon
#include #include #include using namespace std; void DP(int n, vector& m); int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n = 0; cin >> n; vector m(n); for (int i = 0; i > temp; m[i].push_back(temp); } } DP(n, m); sort(m[n - 1].begin(), m[n - 1].end()); cout = 2) { m[1][0] += m[0][0]; m[1][1] += m[0][0]; }..
[C++] 백준 2447 별 찍기
·
Algorithm/Baekjoon
#include #include using namespace std; void star(int num, int x, int y, vector& stars); int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int num; cin >> num; vector stars(num); for (int i = 0; i < num; i++) //생성 { for (int j = 0; j < num; j++) stars[i].push_back('*'); } star(num, 0, 0, stars); for (int i = 0; i < num; i++) //출력 { for (int j = 0; j < num; j++) cout
[C++] 백준 10282 해킹 다익스트라알고리즘
·
Algorithm/Baekjoon
#include #include #include #include using namespace std; #define INF 987654321 const int maxCom = 10001; int n, d, c, test; void dijkstra(int start, int end, vector *com); int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> test; for (int i = 0; i > n >> d >> c; vector computer[maxCom]; for (int j = 0; j < d; j++)//의존되고 있는 것을 기준으로 push_back한다. { in..
[C++] 백준 1325 효율적인 해킹 BFS, DFS
·
Algorithm/Baekjoon
#include #include #include #include #include #define MAX_COM 10001 using namespace std; vector node[MAX_COM]; bool visited[MAX_COM]; vector counts; int BFS(int curr); bool Sorted(pair x, pair y); int main() { ios::sync_with_stdio(false); int N, M, maxCounts = 0; cin >> N >> M; for (int i = 0; i > temp[0] >> temp[1]; node[temp[1]].push_back(temp[0]);//단방향 리스트를 사용한다. ..
[C++] 백준 1012 유기농 배추 DFS, BFS
·
Algorithm/Baekjoon
#include #include #include #define MAX_LENGTH 50 using namespace std; bool node[MAX_LENGTH][MAX_LENGTH]; bool visited[MAX_LENGTH][MAX_LENGTH]; int width, height, counts, result; void DFS(int x, int y); int main() { int T; cin >> T; for (int i = 0; i > width >> height >> counts; result = 0; memset(node, NULL, sizeof(node)); memset(visited, NULL, sizeof(visited)); for (int j = 0; ..
[C++] 백준 2606 바이러스 DFS, BFS
·
Algorithm/Baekjoon
#include #include #include #define COMMAX 101 using namespace std; int netNum, comNum; vector node[COMMAX]; bool visited[COMMAX]; int counts = 0; void BFS(int curr); int main() { ios::sync_with_stdio(false); cin >> comNum; cin >> netNum; for (int i = 0; i > temp[0] >> temp[1]; node[temp[0]].push_back(temp[1]); node[temp[1]].push_back(temp[0]); } BFS(1); cout