제출 #1256879

#제출 시각아이디문제언어결과실행 시간메모리
1256879christhegamechanger축제 (IOI25_festival)C++17
컴파일 에러
0 ms0 KiB
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

static int N, M;
static vector<int> T, H;

void initialize(std::vector<int> t, std::vector<int> h) {
    N = t.size();
    M = h.size();
    T = t;
    H = h;
}

bool can_reach(int L, int R, int S, int D) {
    // If start and destination are the same
    if (S == D) return true;
    
    // BFS to find path from (0,S) to (0,D) within columns [L,R]
    int width = R - L + 1;
    vector<vector<bool>> visited(N, vector<bool>(width, false));
    queue<pair<int, int>> q;
    
    // Start from (0,S)
    // S-L is the column index in our restricted range
    q.push({0, S - L});
    visited[0][S - L] = true;
    
    while (!q.empty()) {
        int row = q.front().first;
        int col_idx = q.front().second;
        q.pop();
        
        // Convert back to actual column
        int actual_col = col_idx + L;
        
        // Check if we reached the destination
        if (row == 0 && actual_col == D) {
            return true;
        }
        
        // Try all 4 adjacent cells
        // Up
        if (row > 0) {
            if (!visited[row - 1][col_idx] && T[row - 1] > H[actual_col]) {
                visited[row - 1][col_idx] = true;
                q.push({row - 1, col_idx});
            }
        }
        
        // Down
        if (row < N - 1) {
            if (!visited[row + 1][col_idx] && T[row + 1] > H[actual_col]) {
                visited[row + 1][col_idx] = true;
                q.push({row + 1, col_idx});
            }
        }
        
        // Left
        if (col_idx > 0) {
            int new_actual_col = (col_idx - 1) + L;
            if (!visited[row][col_idx - 1] && T[row] > H[new_actual_col]) {
                visited[row][col_idx - 1] = true;
                q.push({row, col_idx - 1});
            }
        }
        
        // Right
        if (col_idx < width - 1) {
            int new_actual_col = (col_idx + 1) + L;
            if (!visited[row][col_idx + 1] && T[row] > H[new_actual_col]) {
                visited[row][col_idx + 1] = true;
                q.push({row, col_idx + 1});
            }
        }
    }
    
    return false;
}

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/ccKkhtdq.o: in function `main':
grader.cpp:(.text.startup+0x232): undefined reference to `max_coupons(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status