#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef struct {
    long long x, y;
} Point;

long long manhattan_distance(Point p1, Point p2) {
    return llabs(p1.x - p2.x) + llabs(p1.y - p2.y);
}

long long calculate_cost(Point* points, long long* path, long long n) {
    long long cost = 0;
    cost += manhattan_distance(points[1], points[path[1]]);
    cost += manhattan_distance(points[1], points[path[n - 1]]);
    for (long long i = 1; i < n - 1; ++i) {
        cost += manhattan_distance(points[path[i]], points[path[i + 1]]);
    }
    return cost;
}

void read_input(const char* file, long long* n, Point** points) {
    FILE* f = fopen(file, "r");
    fscanf(f, "%lld", n);
    *points = (Point*)malloc((*n + 1) * sizeof(Point));
    (*points)[0].x = 0;
    (*points)[0].y = 0; // junk point at the beginning
    for (long long i = 1; i <= *n; ++i) {
        fscanf(f, "%lld %lld", &((*points)[i].x), &((*points)[i].y));
    }
    fclose(f);
}

void read_output(const char* file, long long* cost, long long** path, long long n) {
    FILE* f = fopen(file, "r");
    fscanf(f, "%lld", cost);
    *path = (long long*)malloc((n + 1) * sizeof(long long));
    (*path)[0] = 0; // junk point at the beginning
    for (long long i = 1; i <= n; ++i) {
        fscanf(f, "%lld", &((*path)[i]));
    }
    fclose(f);
}

void check_solution(const char* std_output_file, const char* usr_output_file, const char* input_file) {
    long long n;
    Point* points;
    read_input(input_file, &n, &points);

    long long std_cost;
    FILE* std_f = fopen(std_output_file, "r");
    fscanf(std_f, "%lld", &std_cost);
    fclose(std_f);

    long long usr_cost;
    long long* usr_path;
    read_output(usr_output_file, &usr_cost, &usr_path, n);

    if (usr_cost != calculate_cost(points, usr_path, n)) {
        fprintf(stderr, "The cost and path do not match.\n");
        printf("0\n");
    } else if (usr_cost > 2 * std_cost) {
        printf("0\n");
    } else {
        printf("100\n");
    }

    free(points);
    free(usr_path);
}

int main() {
    check_solution("answer", "user_out", "input");
    return 0;
}
