전체 글

개발 등 공부기록용 블로그입니다
그래프: (Graph) 자료구조의 일종으로 그래프는 연결되어 있는 원소 사이의 다대다 관계를 표현하는 자료구조이다. 정점(Node,Vertex) 간선(EDGE):정점간의 관계 로 표현된다 G =(V,E)로 나타낸다 경로: 1에서2에서 가는경로, 1에서 3에서 가는 경로 등이 있다. 사이클 : 정점 1에서 다시 1로 돌아오는 경로 단순경로/단순사이클 : 경로/사이클에서 같은 정점을 두번 이상 방문하지 않는 경로/사이클 보통 말이 없으면 일반적으로 사용하는 경로와 사이클은 단순경로/사이클을 뜻한다 방향있는 그래프/ 방향없는 그래프 양방향 그래프 라고도 한다 루프: 간선의 양 끝점이 같은경우 가중치: 있다면 A에서 B로 이동하는 거리 시간 비용 등등.. 차수 : 정점과 연결되어 있는 간선의 개수 그래프의 표현..
· [백준]/C++
#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include using namespace std; int main() { int N, K; cin >> N >> K; int arr[2][7] = { { 0,0 }, {0,0,0,0,0,0,0} }; int S, Y; for (int i = 0; i > S >> Y; arr[S][Y]++; } int cnt = 0; for (int j = 0; j
· [백준]/C++
#include #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); //닫는거만 세주면 됩니다 //여는 괄호에서 닫는 거 개수만큼 차감해주고 마이너스가 된다면 VPS가 아니죠 int n; cin >> n; while (n--) { string input; cin >> input; int vpsCount = 0; bool minus = false; for (int i = 0; i < input.size(); i++) { if (input[i] == '(') { vpsCount++; } else { vpsCount--; } if (vpsCount < 0) {..
· [백준]/C++
#include #include #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; queue cnt; while (n--) { string input; cin >> input; if (input == "push") { int input2; cin >> input2; cnt.push(input2); } if (input == "pop") { if (!cnt.empty()) { cout
· [백준]/C++
#include using namespace std;int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int arr[10001] = { 0, }; // 좌표의 길이 int N; // 테스트 케이스 cin >> N; int a, b; for (int i = 0; i > a >> b; for (int j = a; j 배열 초기화랑 작대기 길이에 주의, 정점의 개수를 세면 안됩니다
· [백준]/C++
#include #include #include #include using namespace std; int count = 0; void GroupWord(string input,int &count) { bool alp[26] = { 0, }; bool group = true; for(int i = 0; i 0) { if (input[i] != input[i - 1] && alp[input[i] - 97] == true) { group = false; break; } } alp[input[i] - 97] = true; } if (group == true) { count++; } } int main() { ios_base::sync_with_stdio..
· [백준]/C++
#include #include #include #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); vector box; string input = ""; while (true) { getline(cin, input); //한줄 통채로 입력받기 if (input == "END") { break; } reverse(input.begin(), input.end()); //코드 뒤집기 box.push_back(input); } for (int i = 0; i < box.size(); i++) { cout
· [백준]/C++
#include #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int input; cin >> input; int cnt = 0; input = 1000 - input; cnt += input / 500; input = input % 500; cnt += input / 100; input = input % 100; cnt += input / 50; input = input % 50; cnt += input / 10; input = input % 10; cnt += input / 5; input = input % 5; cnt += input / 1; input ..
· [백준]/C++
#include #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string a, b; cin >> a >> b; //모두 5로 바꾼게 최솟값 모두 6으로 바꾼게 최대값 for (int i = 0; i < a.length(); i++) { if (a[i] == '6') { a[i] = '5'; } } for (int i = 0; i < a.length(); i++) { if (b[i] == '6') { b[i] = '5'; } } cout
· [백준]/C++
#include #include #include using namespace std; int a[30][30]; int group[30][30]; int dx[] = {0,0,1,-1}; int dy[] = {1,-1,0,0}; int n; int ans[25*25]; void bfs(int x, int y, int cnt) { queue q; q.push(make_pair(x,y)); group[x][y] = cnt; while (!q.empty()) { x = q.front().first; y = q.front().second; q.pop(); for (int k=0; k