알고리즘

    [백준 9019] DSLR

    bfs를 쓰되 경로를 저장해야 한다. //9019번 DSLR #include #include #include using namespace std; string bfs(int a, int b, vector & path){ string ans = ""; queue q; vector check(10000, 0); q.push(a); check[a] = 1; while(!q.empty()){ int cur = q.front(); q.pop(); //종료 조건 if(cur == b){ while(path[cur].first!= -1){ ans += path[cur].second; cur = path[cur].first; } break; } int next; //D next = (cur * 2) % 10000; i..

    [백준 2615] 오목

    //2615번 오목 #include #include using namespace std; int row = 0; int column = 0; bool check(int k, int l){ if(k >=1 && k=1 && l오), ㅣ(위->아래), \(왼위->오아래) , /(왼아래->오위) vector x = {{0, 0}, {-1, 1}, {-1, 1}, {1, -1}}; //i vector y = {{-1, 1}, {0, 0}, {-1, 1}, {-1, 1}}; //j //보드 탐색 for(int i = 1 ; i