본문 바로가기

코딩

(102)
백준 11725 트리의 부모 찾기 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include using namespace std; int n; class TreeNode { public: int data; vector connections; int connectionSize = 0; TreeNode() { data = 0; } TreeNode(int data) : data(data) {} }; class Tree { public: TreeNode head; int size; Tree(TreeNode head, int size) : head(head), size(size) {} }; int main() { int size; scanf("%d", &size); i..
백준 2261 가장 가까운 두 점 찾기 #include #include using namespace std; int n; struct dot { int x; int y; bool operator>(dot rdot) { return this->y > rdot.y; } bool operatory < rdot.y; } }; dot dotArr[100001]; int dist(int AIndex, int BIndex) { return (dotArr[BIndex].x - dotArr[AIndex].x) * (dotArr[BIndex].x - dotArr[AIndex].x) + (dotArr[BIndex].y - dotArr[AIndex].y) * (dotArr[BIndex].y - dotArr[AIndex].y); } int calc(int start..
백준 1992 쿼드트리 #include #include using namespace std; int canvasSize; bool canvas[64][64]; void consoleInput() { scanf("%d", &canvasSize); for (int i = 0; i < canvasSize; i++) { for (int j = 0; j < canvasSize; j++) { char tmp = getchar(); if (tmp == '\n') { j--; continue; } if (tmp - '0' == 0) canvas[i][j] = false; else canvas[i][j] = true; } } } int isSameColor(int i_start, int i_end, int j_start, int j_end) ..
백준 2740 행렬 곱셈 #include #include using namespace std; int N, M, K; int arrA[100][100]; int arrB[100][100]; int arrResult[100][100]; void consoleInput() { scanf("%d %d", &N, &M); for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) scanf("%d", &arrA[i][j]); scanf("%d %d", &M, &K); for (int i = 0; i < M; i++) for (int j = 0; j < K; j++) scanf("%d", &arrB[i][j]); return; } void printArr(int arr[100][100], int ..
백준 6549 히스토그램에서 가장 큰 직사각형 #include #include #include using namespace std; int n; int height[100002]; stack highestIndexStack; int main() { while (true) { scanf("%d", &n); if (n == 0) return 0; for (int i = 0; i < n + 2; i++) height[i] = 0; for (int i = 1; i result) result = nowArea; } } highestIndexStack.push(i); now++; } cout
백준 1780 종이의 개수 #include #include using namespace std; int paper[2188][2188]; int n; int result[3]; //-1, 0, 1 void consoleInput() { cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { scanf("%d", &paper[i][j]); } } return; } int checkSameNum(int i_begin, int i_end, int j_begin, int j_end) { int start; start = paper[i_begin][j_begin]; for (int i = i_begin; i
백준 11004 K번째 수 #include #include using namespace std; int arr[5000000]; int main() { int n, k; cin >> n >> k; int num = 0; for (int i = 0; i < n; i++) { scanf("%d", &arr[i]); } sort(arr, arr + n); cout
[C#] 백준 2749 피보나치수 3 using System; using System.Collections.Generic; namespace CsharpConsoleApplication { class Matrix { public static int mod = 1000000; public long[,] mat = new long[2,2]; public void setMat(long i0, long i1, long j0, long j1) { mat[0,0] = i0; mat[0,1] = i1; mat[1,0] = j0; mat[1,1] = j1; } public Matrix(long i0, long i1, long j0, long j1) { setMat(i0, i1, j0, j1); } public static Matrix operator*(M..