본문 바로가기

Computer Science/Problem Solving3

BOJ 15683 - 감시 문제 링크 구현이 복잡해서 좀 골치아팠다. 문제 자체가 엄청 복잡하지는 않다. CCTV 들의 위치를 기억해 뒀다가, CCTV 가 감시할 수 있는 모든 방향 조합에 따라 감시가 되는 구역을 조사하고, 감시 되지 않는 곳을 세어주면 된다. 아래 내용이 처음으로 정답을 받은 코드이다. #include using namespace std; typedef pair pii; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; int one[1] = {0}, two[2] = {0, 2}, three[2] = {0, 1}, four[3] = {0, 1, 2}, five[4] = {0, 1, 2, 3}; vector cctv; vector mp; int n, m; void mark(.. 2020. 1. 10.
BOJ 3055 - 탈출 문제 링크 #include using namespace std; typedef pair pii; int r, c, ans, dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; string mp[55]; bool visited[55][55], found = false; vector water; vector loc; bool check(int x, int y) { return 0 r >> c; for(int i = 0; i > mp[i]; for(int i = 0; i < r; ++i) { for(int j = 0; j < c; ++j) { if(mp[i][j] == 'S') { loc.push_back({i, j}); } else if(mp[i][j.. 2020. 1. 10.
BOJ 15686 - 치킨 배달 Originally written on December 07, 2019. 문제 링크 #include using namespace std; typedef pair pii; vector house, chicken; int bitCount(int x) { int ret = 0; while(x > 0) { ret += x & 1; x >>= 1; } return ret; } int d(pii p1, pii p2) { return abs(p1.first - p2.first) + abs(p1.second - p2.second); } int calculate(int mark) { int ret = 0; for(pii h : house) { int k = mark, idx = chicken.size() - 1, dis.. 2020. 1. 10.