Submission #1269715

#TimeUsernameProblemLanguageResultExecution timeMemory
1269715seoul_koreaCOVID tests (CEOI24_covid)C++20
Compilation error
0 ms0 KiB
#include <vector> #include <string> #include <numeric> // For std::iota (if needed for other strategies, not strictly for this one) #include <cmath> // For math functions (if needed for P-dependent strategy) // Global variables N and P are available from the template. // extern int N; // extern double P; // The test_students function is provided by the judge environment. // bool test_students(std::vector<bool> mask); // Hàm đệ quy để tìm các mẫu dương tính trong một khoảng cụ thể [start_idx, end_idx]. // Nó sẽ cập nhật result_mask với các chỉ số của các mẫu dương tính. void find_positive_in_range(int start_idx, int end_idx, std::vector<bool>& result_mask) { if (start_idx > end_idx) { return; // Khoảng không hợp lệ hoặc rỗng } // Tạo một mặt nạ cho khoảng hiện tại [start_idx, end_idx]. // Tất cả các phần tử khác ngoài khoảng này sẽ là false. std::vector<bool> current_test_mask(N, false); for (int i = start_idx; i <= end_idx; ++i) { current_test_mask[i] = true; } // Thực hiện truy vấn xét nghiệm cho nhóm mẫu này. bool is_positive_in_current_range = test_students(current_test_mask); [7] if (!is_positive_in_current_range) { // Không có mẫu dương tính nào trong khoảng này. // Toàn bộ nhánh tìm kiếm này có thể được cắt bỏ. return; } // Nếu có mẫu dương tính trong khoảng này: if (start_idx == end_idx) { // Đây là một khoảng chỉ có một phần tử, và nó đã được xác định là dương tính. // Vì vậy, mẫu của học sinh này chắc chắn dương tính. result_mask[start_idx] = true; return; } // Đối với các khoảng có nhiều hơn một phần tử, chia nó thành hai nửa và đệ quy. int mid_idx = start_idx + (end_idx - start_idx) / 2; // Đệ quy kiểm tra nửa trái. find_positive_in_range(start_idx, mid_idx, result_mask); // Đệ quy kiểm tra nửa phải. find_positive_in_range(mid_idx + 1, end_idx, result_mask); } // Hàm này sẽ được gọi một lần cho mỗi kịch bản. std::vector<bool> find_positive() { std::vector<bool> result_mask(N, false); // Khởi tạo tất cả học sinh là âm tính. // Bắt đầu chiến lược phân tách nhị phân từ toàn bộ dải mẫu [0, N-1]. find_positive_in_range(0, N - 1, result_mask); return result_mask; }

Compilation message (stderr)

Main.cpp: In function 'void find_positive_in_range(int, int, std::vector<bool>&)':
Main.cpp:22:41: error: 'N' was not declared in this scope
   22 |     std::vector<bool> current_test_mask(N, false);
      |                                         ^
Main.cpp:28:41: error: 'test_students' was not declared in this scope
   28 |     bool is_positive_in_current_range = test_students(current_test_mask); [7]
      |                                         ^~~~~~~~~~~~~
Main.cpp:28:76: error: expected identifier before numeric constant
   28 |     bool is_positive_in_current_range = test_students(current_test_mask); [7]
      |                                                                            ^
Main.cpp: In lambda function:
Main.cpp:30:5: error: expected '{' before 'if'
   30 |     if (!is_positive_in_current_range) {
      |     ^~
Main.cpp: In function 'void find_positive_in_range(int, int, std::vector<bool>&)':
Main.cpp:28:78: error: expected ';' before 'if'
   28 |     bool is_positive_in_current_range = test_students(current_test_mask); [7]
      |                                                                              ^
      |                                                                              ;
   29 | 
   30 |     if (!is_positive_in_current_range) {
      |     ~~                                                                        
Main.cpp: In function 'std::vector<bool> find_positive()':
Main.cpp:56:35: error: 'N' was not declared in this scope
   56 |     std::vector<bool> result_mask(N, false); // Khởi tạo tất cả học sinh là âm tính.
      |                                   ^