Use long long.

This commit is contained in:
unlockable
2023-11-06 17:25:25 +08:00
parent b7b8af4811
commit f55fb12e50

View File

@@ -4,6 +4,8 @@
// 'Natural count' is the name of the node when all the nodes in the tree is
// alive. xxx_num denotes the count as the question described.
// SEE ALSO BRANCH 04_02 WITH A CORRECT IMPLEMENTATION
int ans[200] = {0};
long long dead_nodes_num[105] = {0};
int total_dead_nodes = 0;
@@ -16,7 +18,7 @@ struct SeveralContinuedDeadNode {
};
struct SearchResult {
int next_ans_pos; // pos in the ans[] array.
int next_ans_pos; // pos in the ans[] array.
long long count_in_father_line; // natural count.
};
@@ -38,7 +40,8 @@ SearchResult find_node(long long target, long long start_num, int next_dead_node
}
else {
all_dead = false;
long long total_spawned_after = spawned_node_max_num + upper_line[upper_line_iter].length * 2;
long long total_spawned_after =
spawned_node_max_num + upper_line[upper_line_iter].length * 2;
while (dead_nodes_num[next_dead_node_num_ptr] <= total_spawned_after &&
next_dead_node_num_ptr < total_dead_nodes) {
if (dead_nodes_num[next_dead_node_num_ptr] - spawned_node_max_num > 1) {
@@ -123,26 +126,34 @@ SearchResult find_node(long long target, long long start_num, int next_dead_node
int main() {
scanf("%d %d", &total_dead_nodes, &total_target_nodes);
for (int i = 0; i < total_dead_nodes; i++) {
scanf("%d", &dead_nodes_num[i]);
scanf("%lld", &dead_nodes_num[i]);
}
for (int i = 0; i < total_target_nodes; i++) {
scanf("%lld", &target_nodes_num[i]);
}
if (dead_nodes_num[0] == 1) {
for (int i = 0; i < total_target_nodes; i++) {
printf("0\n");
if (target_nodes_num[i] == 1) {
printf("1\n");
continue;
}
else {
printf("0\n");
}
}
return 0;
}
else {
long long current_target = 0;
SeveralContinuedDeadNode firstline = SeveralContinuedDeadNode{ALIVE, 1};
for (int i = 0; i < total_target_nodes; i++) {
scanf("%lld", &current_target);
SearchResult result = find_node(current_target, 2, 0, &firstline, 1, 2);
SearchResult result = find_node(target_nodes_num[i], 2, 0, &firstline, 1, 2);
if (result.count_in_father_line == -1) {
printf("0\n");
}
else {
printf("1 ");
for (int j = result.next_ans_pos - 1; j >= 0; j--) {
printf("%d ", ans[j]);
printf("%lld ", ans[j]);
}
printf("\n");
}