백준 14502 연구소 혼내주기
이중 포문을 nm이 아니라 nn으로 돌다가 오래 헤맸다... 벽을 놓는 dfs를 돌릴 때 매번 0,0에서 시작하지 않고 다음 지점부터 시작하면 시간이 많이 단축된다. 요종도 #include #define fastio ios::sync_with_stdio(0), cin.tie(0) using namespace std; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0 , -1}; queue viruses; bool visited[8][8]; int arr[8][8]; int n, m, ans = 0, walls = 0; void input() { fastio; cin >> n >> m; for(int i = 0; i < n; ++i) { for(int j = 0; j <..
혼내주기
2021. 8. 1. 22:32