From 32bd7e91fd68b54a0ac8711338b46f17007cc306 Mon Sep 17 00:00:00 2001 From: unlockable Date: Sun, 5 Nov 2023 10:52:27 +0800 Subject: [PATCH] 1, 2, 3, 4, 7AC. --- 2023204/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/2023204/main.cpp b/2023204/main.cpp index fab214c..96a970a 100644 --- a/2023204/main.cpp +++ b/2023204/main.cpp @@ -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;