본문 바로가기

알고리즘/구현6

백준 14503번 : 로봇 청소기 문제 링크 : www.acmicpc.net/problem/14503 내 풀이(2021.1.10) : #include using namespace std; int N, M; int map[50][50]; // [y][x] int visit[50][50]; // [y][x] int _left[4][2] = { { 0, -1}, // 북쪽 {-1, 0}, // 동쪽 { 0, 1}, // 남쪽 { 1, 0}, // 서쪽 }; int back[4][2] = { { 1, 0}, // 북쪽 { 0, -1}, // 동쪽 {-1, 0}, // 남쪽 { 0, 1}, // 서쪽 }; void show_map() { for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { c.. 2021. 1. 10.
백준 10757번 : 큰 수 A+B 문제 링크 : www.acmicpc.net/problem/10757 내 풀이(2021.1.4.) : #include #include using namespace std; int a[1251]; // A int b[1251]; // B string c[1251]; // 결과 // 1~8글자짜리 int를 8글자짜리 string으로 변환 string num2str(int num) { string str = to_string(num); string result = "00000000"; for (int i = 0; i < str.size(); i++) { result[8 - str.size() + i] = str[i]; } return result; } int main() { ios_base::sync_with_.. 2021. 1. 4.
백준 14891번 : 톱니바퀴 문제 링크 : www.acmicpc.net/problem/14891 풀이에 참조한 링크 : * 벡터의 insert, erase - hsdevelopment.tistory.com/164 * 반례 - www.acmicpc.net/board/view/50149 내 풀이(2021.1.3.) : #include #include #include #include using namespace std; vector wheel[5]; void clockwise(int num) { vector& v = wheel[num]; int temp = v.back(); v.pop_back(); v.insert(v.begin(), temp); } void counterclockwise(int num) { vector& v = whee.. 2021. 1. 3.
백준 2167번 : 2차원 배열의 합 문제 링크 : www.acmicpc.net/problem/2167 내 풀이(2021.1.2.) : #include using namespace std; int arr[300][300] = { 0 }; // [x][y] int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int N, M; cin >> N >> M; for (int j = 0; j > temp; arr[i][j] = temp; } } int K; cin >> K; for (int k = 0; k < K; k++) { int sum = 0; int i, j, x,.. 2021. 1. 2.