1, 2, 3, 4, 7AC.
This commit is contained in:
@@ -72,7 +72,7 @@ SearchResult find_node(int target, int start_num, int next_dead_node_num_ptr,
|
||||
|
||||
if (target <= spawned_node_max_num) {
|
||||
ans[0] = target;
|
||||
int natural_pos = 0, num = start_num;
|
||||
int natural_pos = -1, num = start_num -1;
|
||||
for (int i = 0; i < current_line_len; i++) {
|
||||
if (current_line_node[i].status == DEAD) {
|
||||
natural_pos += current_line_node[i].length;
|
||||
@@ -89,7 +89,7 @@ SearchResult find_node(int target, int start_num, int next_dead_node_num_ptr,
|
||||
num += current_line_node[i].length;
|
||||
}
|
||||
else {
|
||||
// if we made it here, then the target <= num + current_line_node[i].length
|
||||
// if we made it here, then the target > num + current_line_node[i].length
|
||||
return SearchResult{1, (natural_pos + target - num) / 2};
|
||||
}
|
||||
}
|
||||
@@ -104,14 +104,14 @@ SearchResult find_node(int target, int start_num, int next_dead_node_num_ptr,
|
||||
return SearchResult{1, -1};
|
||||
}
|
||||
|
||||
int natural_count = 0, num = start_num;
|
||||
int natural_count = -1, num = start_num - 1;
|
||||
for (int i = 0; i < current_line_len; i++) {
|
||||
natural_count += current_line_node[i].length;
|
||||
if (current_line_node[i].status == ALIVE || current_line_node[i].length == 1) {
|
||||
num += current_line_node[i].length;
|
||||
}
|
||||
|
||||
if (natural_count > current_line_pos.count_in_father_line) {
|
||||
if (natural_count >= current_line_pos.count_in_father_line) {
|
||||
num -= natural_count - current_line_pos.count_in_father_line;
|
||||
ans[current_line_pos.next_ans_pos++] = num;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user