백준 (C언어)백준 1157번 단어 공부 #include #include #include int main() { char arr[1000009]; int i = 0; int check[26] = {0}; int max = 0; char alph; scanf("%s", arr); int size = strlen(arr); for (int k = 0; k max) { max = check[i]; alph = 'A' + i; } else if (max != 0 && max == che.. 초기 네이버 기록/알고리즘(C) 2023.01.05
백준 2910번 빈도정렬 (C++)(stable, unordered_map, find와 find_if,람다식,stable_sort) 문제와 정말 정말 오래걸린 문제이다.살짝 부끄럽지만 일단은 내가 vector, pair ,stable_sort, map ,unordered_map,find,find_if 등에 대해서 공부하는 시간이 됐다.정답 코드#include #include #include #include #include using namespace std; bool my_sort(pair a,pair b) { return (a.second > b.second); } int main() { ios :: sync_with_stdio(0); cin.tie(0); int n,c; cin >> n >> c; vectorarr; int num; for (int i=0;i > num; auto a = find_if(.. 알고리즘/백준-실버 2023.01.05
백준 2828번 사과 담기 게임(C++) 문제정답 코드#include using namespace std; int main() { int N,M,j; cin >> N>> M >> j; int L = 1; int aloc; int cnt =0; M--; for (int i=0;i > aloc; if (L 알고리즘/백준-실버 2023.01.05
백준 1992번 쿼드트리 (C++) 문제정답 코드#include #include #include #include using namespace std; int check_all_same(int x,int y,int size,vector &bmap) { int start = bmap[y][x]; for (int i=y; i < y + size;i++) { for (int j=x; j 알고리즘/백준-실버 2023.01.05
백준 2583번 영역 구하기(C++) 문제정답 코드#include #include #include #include #include #include #include #include using namespace std; #define X first #define Y second int map[102][102]; int mx[4] ={0,1,0,-1}; int my[4] ={1,0,-1,0}; int all; int result[10000]; // void printmap(int col,int row) // { // for (int i=col -1; i >= 0;i--) // { // for (int j=0; j row >> snum; for(int i=0; i> .. 알고리즘/백준-실버 2023.01.05
백준 2468번 안전영역(C++) 문제정답 코드#include #include #include #include #include #define X first #define Y second using namespace std; const int dx[]= {0,1,0,-1}; const int dy[]= {1,0,-1,0}; int main() { ios :: sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector arr(n,vector(n,0)); vector vis(n,vector(n,0)); for (int i=0;i > arr[i][j]; } } int len = 1; int result = -1; int max = 1; while (result !=0) { result = 0; for (.. 알고리즘/백준-실버 2023.01.05
백준 1012번(C++) 문제정답 코드#include #include #include #include using namespace std; const int mx[] = {0,1,0,-1}; const int my[] = {1,0,-1,0}; int main() { int t,m,n,k; cin >> t; int cnt = 0; for (int i =0; i > m >> n>> k; vector arr(n,vector(m,0)); vector vis(n,vector(m,0)); for (int j =0; j > x>> y; arr[y][x] = 1; } for (int iy = 0;iy < n;iy++) { for (int ix = 0;ix < m;ix++.. 알고리즘/백준-실버 2023.01.05
백준 (C언어)백준 1152번 단어의 갯수 scanf ("%[^\n]") 이 문제는 처음에 scanf를 스페이스 말고 개행을 기준으로 받는 방법을 몰라서 헤맸었다. #include #include #include int main() { char arr[1000000]; scanf("%[^\n]", arr); int count = 1; int size = strlen(arr); for (int i = 0; i < size; i++) { if (arr[i] == ' ') count++; } if (arr[0] == ' ') count--; if (arr[size - 1] == ' ') count--; printf("%d", count); } 이 글은 코딩 꼬꼬마 시절에 푼 문제를 보관한 글로 네이버에 저장해둔 글을 옮긴 글입니다. 혹시나 참고하시는 부분에 이상한 부분이나 질문이 .. 초기 네이버 기록/알고리즘(C) 2023.01.04
백준 (C언어)백준 2869번 달팽이 (시간복잡도 문제) 이전에 풀었던 문제중에 시간복잡도에 자꾸 걸렸던 문제가 있었는데 시간복잡도를 줄이는 방법은 1. 함수의 호출의 수를 최대한 줄인다. 2. 미리할 수 있는 연산은 미리 끝내고 반복문에 들어간다. 3. 이번에 풀 문제인데 탐색할 때 값을 계속 올리면서 찾는 것보다 수식으로 풀고 코드를 짜는게 낫다는 거다. #include int main() { unsigned int up, down; unsigned int high; scanf("%d%d%d", &up, &down, &high); unsigned int day = 1; unsigned int cha = up - down; unsigned int real_high = high - down; while (1) { if (real_high =high 니까 이항해.. 초기 네이버 기록/알고리즘(C) 2023.01.04
백준 (C언어)백준 2775번 부녀회장문제 재귀 아닌 배열문제 #include int main() { int input, floor, room; scanf("%d", &input); int arr[15][15]; for (int i = 1; i 초기 네이버 기록/알고리즘(C) 2023.01.04