목록알고리즘 문풀/백준 (24)
혼자 정리
문제링크 C++ #include #include #include using namespace std; int T, k; int check[1000001]; int main(){ ios::sync_with_stdio(0); cin.tie(0); cin >> T; for (int i = 0; i > n; for (int i = 0; i > chartmp >> inttmp; if (chartmp == 'I'){ minval.push({inttmp, i});..
문제링크 C++ #include #include #include #include using namespace std; int N, M; unordered_map ladder, snake; queue Q; int dist[101]; int main(){ ios::sync_with_stdio(0); cin.tie(0); cin >> N >> M; int tmp1, tmp2; for (int i = 0; i > tmp1 >> tmp2; ladder[tmp1] = tmp2; } for (int i = 0; i > tmp1 >> tmp2; snake[tmp1] = tmp2; } memset(dist, -1, sizeof(dist)); dist[1] = 0;..
문제링크 C++ #include #include using namespace std; int N; int matrix[101][101]; int ret[101][101]; int visited[101]; void dfs(int start, int nod){ if (visited[nod] == 1) return ; visited[nod] = 1; for (int i = 1; i > N; for (int i = 1; i matrix[i][j]; } } for (int i = 1; i
문제링크 C++(BFS) #include #include #include #include using namespace std; unsigned short N; unsigned int M; unsigned short u, v; vector adj_lst[1001]; char visited[1001]; queue Q; int main(){ ios::sync_with_stdio(0); cin.tie(0); cin >> N >> M; for (int i = 0; i > u >> v; adj_lst[u].push_back(v); adj_lst[v].push_back(u); } int ret = 0; for (int t = 1; t > M; for (int i = 0; i < M; i+..
문제링크 C++ #include using namespace std; int T, M, N, x, y; int ret; int gcd(int a, int b){ while (b > 0){ int r = a % b; a = b; b = r; } return (a); } int lcm(int a, int b){ return (a * b / gcd(a, b)); } int main(){ ios::sync_with_stdio(0); cin.tie(0); cin >> T; for (int i = 0; i > M >> N >> x >> y; ret = -1; int tmp = x; int cnt = x; for (int j = 0; j < N; j++){ int yy; if (tmp %..
문제링크 C++ #include using namespace std; int memo[1001]; int n; void dp(int n); int main(){ ios::sync_with_stdio(0); cin.tie(0); cin >> n; dp(n); cout
문제링크 C++ #include using namespace std; int N, M; int arr[100001]; int sum[100001]; int main(){ ios::sync_with_stdio(0); cin.tie(0); cin >> N >> M; for (int i = 1; i > arr[i]; sum[i] = sum[i - 1] + arr[i]; } for (int idx = 1; idx > i >> j; cout
문제링크 C++ #include #include using namespace std; int T; unordered_map my_map; int main(){ ios::sync_with_stdio(0); cin.tie(0); cin >> T; for (int i = 0; i > n; string tmp1, tmp2; my_map.clear(); for (int j = 0; j > tmp1 >> tmp2; if (my_map.count(tmp2) == 0) { my_map[tmp2] = 1; } else { my_map[tmp2]++; } } int ret = 1; for (auto i = my_map.begin(); i != my_..
문제링크 C++ #include #include using namespace std; int N, M; map m1; int main(){ ios::sync_with_stdio(0); cin.tie(0); cin >> N >> M; for (int i = 0; i > tmp1 >> tmp2; m1.insert(pair(tmp1, tmp2)); } for (int i = 0; i > tmp; cout second
문제링크 C++ #include using namespace std; typedef unsigned int uint; uint g[5]; uint K; uint g_rot[5]; void rotate_to_left(uint loc, uint rot){ if (loc - 1 > 0){ if (((g[loc - 1] & 0b00100000) != 0) != ((g[loc] & 0b00000010) != 0)){ g_rot[loc - 1] = rot * (-1); rotate_to_left(loc - 1, rot * (-1)); } } } void rotate_to_right(uint loc, uint rot){ if (loc + 1 = 1; g[i] |= 0b10000000; }else{ g[i] >>= 1..