목록Problem Solving (49)
프로그래밍 공부
https://www.acmicpc.net/problem/6593 해결 아이디어그냥 bfs를 3차원으로 돌려주면 해결되는 문제였다#include #include #include #define X second.second#define Y second.first#define Z firstusing namespace std;int dx[] = {0,0,0,0,1,-1};int dy[] = {0,0,1,-1,0,0};int dz[] = {1,-1,0,0,0,0};int main(){ ios::sync_with_stdio(0); cin.tie(0); while(1){ char board[31][31][31]; int vis[31][31][31]; memset(..
https://www.acmicpc.net/problem/14940 해결 아이디어그냥 bfs를 돌리면서 현재 위치의 값에서 +1를 해준 값을 넣어서 거리를 탐색하고시작지점으로 부터 탐색이 끝난 후에 board의 값이 0이나 2가 아닌데 vis의 값이 0이면 벽은 아니지만 탐색이 불가능 한 지역이니거기서 부터 다시 bfs를 돌려서 문제를 해결했다.#include #include #include using namespace std;#define X first#define Y secondint dx[] = {0, 1, 0, -1};int dy[] = {1, 0, -1, 0};int main(){ ios::sync_with_stdio(0); cin.tie(0); int n, m; cin >..
https://www.acmicpc.net/problem/3190 해결 아이디어 문제를 읽어보니 시뮬레이션 문제인거 같았다 솔직히 구현은 그냥 주어진대로 코드를 작성하면 될 것 같았고중요한건 방향전환 부분과 몸이 벽이나 몸이 부딛칠때 그 부분을 처리하는게 중요한 것 같았다. 솔직히 말하면 방향전환 부분은 자력으로 해결하지는 못했고 인터넷 검색을 통해 알게 되었고 이를 바탕으로 해결하게 되었다.int dx[] = {0, 1, 0, -1}; // 오른쪽, 아래, 왼쪽, 위int dy[] = {1, 0, -1, 0};dir = (dir + 3) % 4; // 왼쪽으로 90도 회전dir = (dir + 1) % 4; // 오른쪽으로 90도 회전이 부분이 방향전환 핵심 아이디어이다 먼저, 뱀의 방향은 정수로 표..
https://www.acmicpc.net/problem/13335 해결 아이디어일단 트럭시 순차적으로 진행 한다는 것을 확인 했으니 큐를 사용해서 문제를 해결하면 될것으로 판단 했고다리 상태를 체크할 수 있는 Vector를 만들어서 검사 하는 식으로 문제를 해결 했다.#include #include #include #include using namespace std;int main() { ios::sync_with_stdio(0); cin.tie(0); int n, w, l; queue q; // pair의 first는 트럭의 무게 second는 현재 남은 거리 vector> bridge; cin >> n >> w >> l; for (int i ..
https://www.acmicpc.net/problem/11866 해결 아이디어대놓고 큐를 써보는 문제카운터 변수를 두고 k횟수 만큼 조건이 채워지면 pop 하는식으로 큐가 empty 해질때 까지 반복#include #include #include using namespace std;int main(){ ios::sync_with_stdio(0); cin.tie(0); int n, k; vector ans; queue q; cin >> n >> k; for(int i = 1; i "; else cout
https://www.acmicpc.net/problem/2304 해결 아이디어가장 높은 기둥을 기준으로 양쪽의 면적을 계산해주는 방식으로 문제를 해결 하면 될 것 같았다.지금은 알고리즘을 복습하는 단계라서 문제 태그를 보고 또 연습을 하면서 푸느라 스택을 사용해서 풀었으나 솔직히그냥 브루트포스로 풀어도 시간초과가 나지 않을 것 같았다.#include #include #include #include using namespace std;int main(){ ios::sync_with_stdio(0); cin.tie(0); int n, ans = 0; cin >> n; vector> v; stack> s, s2; for(int i = 0; i > l >> h; ..