제출 #1221521

#제출 시각아이디문제언어결과실행 시간메모리
1221521slimsavern모자이크 (IOI24_mosaic)C++20
컴파일 에러
0 ms0 KiB
#include <vector> #include <cstdint> #include "mosaic.h" using namespace std; vector<int64_t> mosaic( const vector<int>& X, const vector<int>& Y, const vector<int>& T, const vector<int>& B, const vector<int>& L, const vector<int>& R) { int N = X.size(), Q = T.size(); // Use 1D flat arrays for cache efficiency vector<int> A(N * N, 0); vector<int64_t> S((N + 1) * (N + 1), 0); auto idx = [&](int i, int j) { return i * N + j; }; auto sidx = [&](int i, int j) { return i * (N + 1) + j; }; // First row and column for (int j = 0; j < N; ++j) A[idx(0, j)] = X[j]; for (int i = 0; i < N; ++i) A[idx(i, 0)] = Y[i]; // Fill in the rest of the A matrix for (int i = 1; i < N; ++i) { for (int j = 1; j < N; ++j) { A[idx(i, j)] = (A[idx(i - 1, j)] == 0 && A[idx(i, j - 1)] == 0) ? 1 : 0; } } // 2D prefix sum into 1D array for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { S[sidx(i + 1, j + 1)] = A[idx(i, j)] + S[sidx(i, j + 1)] + S[sidx(i + 1, j)] - S[sidx(i, j)]; } } // Answer the queries vector<int64_t> res(Q); for (int k = 0; k < Q; ++k) { int t = T[k], b = B[k], l = L[k], r = R[k]; res[k] = S[sidx(b + 1, r + 1)] - S[sidx(t, r + 1)] - S[sidx(b + 1, l)] + S[sidx(t, l)]; } return res; }

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

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