목록Algorithm/C++ (148)
cgy12306
// https://www.acmicpc.net/problem/14890 // 경사로 // reference by wizely #include #include using namespace std; int N, L; int map[101][101] = { 0, }; int res = 0; void checkX(int x) { int cnt = 1; for (int j = 0; j = L) cnt = 1; // 경사가 내려막길일 경우 cnt를 -L..
// https://www.acmicpc.net/problem/14499 // 주사위 굴리기 #include #include using namespace std; int N, M, x, y, K; int map[21][21]; int dice[8]; int tmpdice[8]; int dx[] = {0, 0, 0, -1, 1}; int dy[] = {0, 1, -1, 0, 0}; void roll(int cmd) { memcpy(tmpdice, dice, sizeof(dice)); // 동 if (cmd == 1) { dice[1] = tmpdice[3]; dice[3] = tmpdice[6]; dice[4] = tmpdice[1]; dice[6] = tmpdice[4]; } // 서 else if (c..
// https://www.acmicpc.net/problem/13458 // 시험 감독 #include using namespace std; int arr[1000001]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int N, B, C; cin >> N; for (int i = 0; i > arr[i]; } cin >> B >> C; long long cnt = 0; for (int i = 0; i 0) { cnt += arr[i] / C; if (arr[i] % C > 0) cnt++; } } cout
// https://www.acmicpc.net/problem/14503 // 로봇 청소기 #include using namespace std; int map[51][51]; bool visited[51][51]; int r, c, x, y, dir; int dx[] = {0, -1, 0, 1}; int dy[] = {-1, 0, 1, 0}; int cnt = 0; void clear(int x, int y) { visited[x][y] = true; map[x][y] = 2; cnt++; } bool turn_go() { int nx = x + dx[dir]; int ny = y + dy[dir]; //cout > y >> dir; for (int i = 0; i < r; i++) { for (int ..
// https://www.acmicpc.net/problem/20055 // 컨베이어 벨트 위의 로봇 #include #include using namespace std; int N, K, belt[201]; bool robot[201]; void curl() { int tmp1, tmp2; tmp1 = belt[2 * N]; tmp2 = robot[2 * N]; for (int i = N * 2 ; i > 1; i--) { belt[i] = belt[i - 1]; robot[i] = robot[i - 1]; } belt[1] = tmp1; robot[1] = tmp2; robot[N] = false; } void move() { for (int i = N - 1; i > 0 ; i--) { if (!..
// https://www.acmicpc.net/problem/2947 // 나무조각 #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int wood[6]; for (int i = 0; i > wood[i]; } for (int k = 0; k wood[i + 1]) { swap(wood[i], wood[i + 1]); for (int j = 0; j < 5; j++) { cout
// https://www.acmicpc.net/problem/17070 // 파이프 옮기기1 #include using namespace std; int N, cnt; int map[17][17]; int dx[] = { 0, 1, 1 }; int dy[] = { 1, 1, 0 }; // 가로 1, 대각 2, 가로 3 bool check(int x, int y, int dir) { int nx = x + dx[dir]; int ny = y + dy[dir]; if (nx >= N || ny >= N || map[nx][ny] == 1) return false; if (dir == 0) { if (map[x][y+1] == 1) return false; } else if (dir == 1) { for (..