#include using namespace std; vector vec[100001]; //간선 저장용 vector dp; //dp용 vector v; //방문처리용 void loop(int r) { //DFS for(int x : vec[r]) { if(!v[x]) { v[x] = true; //방문처리 loop(x); dp[r] += dp[x]; } } } int main(void) { ios::sync_with_stdio(0); cin.tie(0); int n, r, q; cin >> n >> r >> q; dp.assign(n+1, 1); v.assign(n+1, false); for(int i=1; i> a >> b; vec[a].emplace_back(b); vec[b].emplace_bac..
#include #define Q q.front() using namespace std; int n, m, ans = 1e9, blank = 0; int Map[50][50] = {}; vector virus; vector vec; int V[4] = {-1, 0, 1, 0}, H[4] = {0, 1, 0, -1}; void BFS() { queue q; //큐 int tmp = 0, cnt = 0; //tmp는 탐색 level, cnt는 0을 채운 개수 bool v[n][n]; //방문 확인 memset(v, false, sizeof(bool)*n*n); //초기화 for(pair i : vec) { //활성화 할 바이러스들을 큐에 삽입 및, 방문 처리 int x = i.first; int y = i...
#include #define Q q.front() using namespace std; int V[4] = {-1, 0, 1, 0}; int H[4] = {0, 1, 0, -1}; int n, m, zero = -3; //벽 3개를 무조건 설치하므로 -3으로 시작합니다. int Max = 0; int Map[8][8] = {}; vector two; void bfs(void) { //bfs queue q; //큐 int cnt = zero; //벽 3개를 설치한 이후 0의 개수 bool v[n][m]; //방문 확인 배열 memset(v, false, sizeof(bool)*n*m); //방문 확인 for(pair i : two) q.push({i.first, i.second}); //바이러스인 곳을 ..
var a : array[1..90] of integer; i, j, n : Integer; c : char; b : array[1..12] of Char; begin b := 'BRONZESILVER'; readln(n); for i:=1 to n do begin read(c); a[byte(c)] := a[byte(c)] + 1; end; i:=1001; a[byte('E')] := a[byte('E')] div 2; a[byte('R')] := a[byte('R')] div 2; n := 12; for j:=1 to n do begin if a[byte(b[j])] < i then i := a[byte(b[j])]; end; write(i); end. 풀이 : 문자별로 입력된 개수 만큼 + 을 해준..

#include #define Q q.front() using namespace std; int main(void) { ios::sync_with_stdio(0); cin.tie(0); int n, m, a, b, c; //a, b, c는 입력을 위한 변수 cin >> n >> m; vector vec[n+1]; //간선의 정보를 담을 벡터 queue q; //BFS에서 사용할 큐 for(int i=1; i> a >> b >> c; vec[a].push_back({b, c}); vec[b].push_back({a, c}); } for(int i=0; i> a >> b; q.push({a, 0}); //큐에 시작노드와 가중치를 0 으로 넣음 v[a] = true; while(!q.empty()) { //B..
#include #define Q q.front() using namespace std; struct A { A(int a, int b, int c, int d) : x(a), y(b), z(c), value(d) {} int x, y, z, value; }; int main(void) { ios::sync_with_stdio(0); cin.tie(0); int V[4] = {-1, 0, 1, 0}; int H[4] = {0, 1, 0, -1}; int n, m, min = 1e9; cin >> n >> m; if(n==1 && m==1) { cout map[i]; bool v0[n][m]; memset(v0, false, sizeof(bool)*n*m); bool v1[n][m]; memset(v1, ..
#include using namespace std; int main(void) { ios::sync_with_stdio(0); cin.tie(0); int s, ans = 1e9; cin >> s; queue q; q.push(make_tuple(1, 1, 1)); bool v[1001] = {}; //방문확인 while(!q.empty()) { //bfs int now = get(q.front()); int copy = get(q.front()); int value = get(q.front()); q.pop(); if(now == s) { //원하는 개수로 맞추었다면 탐색 종료 ans = value; break; } value++; //수행시간 1 증가 if(now 2) q.push(make_tupl..
#include using namespace std; int main(void) { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while(t--) { int a, b; queue q; cin >> a >> b; q.push(make_tuple(a, b, 0)); while(!q.empty()) { int x = get(q.front()); int y = get(q.front()); int v = get(q.front()); q.pop(); x *= 2; y += 3; v++; if(x < y) q.push(make_tuple(x, y, v)); else if(x==y) { cout
- Total
- Today
- Yesterday
- Krustal
- C++
- 오프라인 쿼리
- 1835
- 최대공약수
- 브루트포스
- 덱
- 1835번
- C언어
- PASCAL
- 그래프
- 정렬
- 기하학
- 그리디
- java
- DP
- 누적합
- 백준
- Lazy Propagation
- 최소 스패닝 트리
- union
- DFS
- 누적 합
- 세그먼트 트리
- Segment Tree
- find
- 스택
- 플로이드
- BFS
- XOR
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |