From 6dc3dae8f8bfab29b2060d2c24bb1e4f5231f23d Mon Sep 17 00:00:00 2001 From: oncsr Date: Wed, 10 Dec 2025 23:58:07 +0900 Subject: [PATCH] =?UTF-8?q?[20251210]=20BOJ=20/=20G5=20/=20=EA=B3=B5?= =?UTF-8?q?=EC=A3=BC=EB=8B=98=EC=9D=84=20=EA=B5=AC=ED=95=B4=EB=9D=BC!=20/?= =?UTF-8?q?=20=EA=B6=8C=ED=98=81=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... \352\265\254\355\225\264\353\235\274!.md" | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 "khj20006/202512/10 BOJ G5 \352\263\265\354\243\274\353\213\230\354\235\204 \352\265\254\355\225\264\353\235\274!.md" diff --git "a/khj20006/202512/10 BOJ G5 \352\263\265\354\243\274\353\213\230\354\235\204 \352\265\254\355\225\264\353\235\274!.md" "b/khj20006/202512/10 BOJ G5 \352\263\265\354\243\274\353\213\230\354\235\204 \352\265\254\355\225\264\353\235\274!.md" new file mode 100644 index 00000000..bc9dcfff --- /dev/null +++ "b/khj20006/202512/10 BOJ G5 \352\263\265\354\243\274\353\213\230\354\235\204 \352\265\254\355\225\264\353\235\274!.md" @@ -0,0 +1,44 @@ +```cpp +#include +using namespace std; + +const int dx[4] = {1,0,-1,0}; +const int dy[4] = {0,1,0,-1}; + +int N, M, T; +int arr[100][100]{}; +queue> q; +bool vis[100][100]{}; +int paint = 1234567; + +int main() { + cin.tie(0)->sync_with_stdio(0); + + cin>>N>>M>>T; + for(int i=0;i>arr[i][j]; + + q.emplace(0,0,0); + vis[0][0] = 1; + while(!q.empty()) { + auto [x,y,t] = q.front(); q.pop(); + if(arr[x][y] == 2) { + paint = t + abs(N-x-1) + abs(M-y-1); + } + if(x == N-1 && y == M-1) { + int val = min(paint, t); + if(val > T) cout<<"Fail"; + else cout<=N || yy<0 || yy>=M || vis[xx][yy] || arr[xx][yy] == 1) continue; + vis[xx][yy] = 1; + q.emplace(xx,yy,t+1); + } + } + if(paint > T) cout<<"Fail"; + else cout<