| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1331702 | nguyengiabach1201 | Ancient Machine (JOI21_ancient_machine) | C++20 | 0 ms | 0 KiB |
#include "Anna.h"
#include <vector>
void Anna(int N, std::vector<char> S) {
for (int i = 0; i < N; i++) {
if (S[i] == 'X') {
Send(0); Send(0);
} else if (S[i] == 'Y') {
Send(0); Send(1);
} else if (S[i] == 'Z') {
Send(1); Send(0);
}
}
}#include "Bruno.h"
#include <vector>
#include <stack>
void Bruno(int N, int L, std::vector<int> A) {
std::vector<char> S(N);
for (int i = 0; i < N; i++) {
int b1 = A[i * 2];
int b2 = A[i * 2 + 1];
if (b1 == 0 && b2 == 0) S[i] = 'X';
else if (b1 == 0 && b2 == 1) S[i] = 'Y';
else S[i] = 'Z';
}
std::vector<bool> removed(N, false);
std::vector<int> x_indices;
std::vector<pair<int, int>> xy_pairs; // Lưu cặp (X, Y)
std::vector<int> good_y; // Các Y tạo thành good removal
// Bước 1: Tìm các bộ (X, Y, Z) tiềm năng
int last_x = -1;
std::vector<int> current_x_stack;
// Logic đơn giản: Tìm X, sau đó tìm Y gần nhất, sau đó tìm Z gần nhất
// Lưu ý: Đây là logic cơ bản, bạn có thể tối ưu thêm để đạt điểm tối đa
std::vector<int> order;
// ... thực hiện logic tìm kiếm và đẩy vào order ...
// Bruno phải gọi Remove(d) đúng N lần [cite: 57]
for (int i = 0; i < N; i++) {
// Thứ tự xóa quan trọng: Xóa các thiết bị không tạo good removal trước,
// sau đó xóa Y trong bộ (X, Y, Z) để tính điểm[cite: 15].
// Ví dụ tạm thời: xóa theo thứ tự 0 đến N-1
Remove(i);
}
}