목록백준/골드 (3)
Taene's
https://www.acmicpc.net/problem/1068 #include #include using namespace std;int N, temp, root, removeNode;vector node[50];int dfs(int searchNode){ int ret = 0; int child = 0; for (auto i : node[searchNode]) { if (i == removeNode) continue; ret += dfs(i); child++; } if (!child) return 1; return ret;}int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> N; for (int i = 0; i ..
https://www.acmicpc.net/problem/2636 // 자기자신이 1이라면 (adj[y][x]==1) 방문한것도 알수있고 vector에 넣고 return할 수 있다.#include #include using namespace std;int N, M;int adj[100][100];bool visited[100][100];vector> eraser;int ret, hour;int dy[] = { -1,1,0,0 };int dx[] = { 0,0,-1,1 };void OneHour(int y, int x){ visited[y][x] = 1; if (adj[y][x] == 1) { eraser.push_back({ y,x }); return; } for (int i = 0; i = N ||..
https://www.acmicpc.net/problem/14502 // 로직 1번 - 최대 64개 중 3개를 골라 벽을 세운다(조합)// 로직 2번 - 최대 64개 중 바이러스(2)가 있는 곳으로부터 바이러스를 퍼트린다(dfs, bfs)// 로직 3번 - 최대 64개 중 바이러스가 없는 안전구역(0)의 넓이를 구한다(counting)// 최대 시간복잡도는 대충 64C3 * (64 + 64) ~= 5,000,000으로 시간복잡도 천만 이하는 효율 고려하지 않고 무식하게 푼다.#include #include #include using namespace std;int N, M;int adj[8][8];bool visited[8][8];vector> wall;vector> virus;int dy[] = { -..