'알고리즘 모음집/New 알고리즘' 카테고리의 글 목록 (7 Page)
본문 바로가기
728x90
반응형

알고리즘 모음집/New 알고리즘219

2022-04-26-17779-게리맨더링2 01.1번구역지정 void one(int x, int y, int d1, int d2) { for (int i = 1; i < x + d1; i++) { for (int j = 1; j 2022. 4. 28.
2022-04-26-21611-마법사상어와블리자드 01.불마법 void magic(int dir, int S) { int y = (N + 1) / 2; int x = (N + 1) / 2; y--; x--; for (int s = 1; s = 4) {//제거 flag = 1; if (O[i] == 1) one += cnt; if (O[i] == 2)two += cnt; if (O[i] == 3)three += cnt; O.erase(O.begin() + i, O.begin() + j); i--; break; } else break; } } if (flag == 0)break; } 04.새로운 구슬 생성 for (int i = 0; i < O.size(); i++) {//새로운 구슬 생성 if (O.size() == 0)break; int cnt = 0;.. 2022. 4. 26.
2022-04-25-21610-마법사상어와비바라기 01.구름이동 int dir, S; scanf("%d %d", &dir, &S); S = S % N; for (int c = 0; c < cloud.size(); c++) {// 구름이동 for (int s = 0; s < S; s++) { Data n; n.y = cloud[c].y + dy[dir]; n.x = cloud[c].x + dx[dir]; if (n.y == 0) n.y = N; else if (n.y == N + 1)n.y = 1; if (n.x == 0) n.x = N; else if (n.x == N + 1)n.x = 1; cloud[c].y = n.y; cloud[c].x = n.x; } } 02.구름 위치에 비1씩 증가 int visit[NS][NS] = { 0 };// 사라지는 .. 2022. 4. 25.
2022-04-25-20057-마법사상어와토네이도 01.달팽이 배열 움직임 while (1) { if (y == 2 && x == 2)break; if (N - 1 == num) cnt = 3; for (int c = 0; c < cnt; c++) { for (int n = 0; n < num; n++) { int ny = y + dy[dir]; int nx = x + dx[dir]; int sum = 0; for (int i = 0; i < 9; i++) { int nny = ny + dy_rate[dir][i]; int nnx = nx + dx_rate[dir][i]; int sand = board[ny][nx] * rate[i]; board[nny][nnx] += sand; sum += sand; } board[ny][nx] -= sum; boar.. 2022. 4. 25.
728x90
반응형