编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#5854 #1059. 牛车采矿 Accepted 100 474 ms 576 K C++ 17 / 4.1 K s230026152 2024-08-17 16:21:43
显示原始代码
/**
 * @title: ..
 * @desc: ..
 * @tag: IO
 * @url:
 */

#include <bits/stdc++.h>

/*
 *
 *   宏定义模板常量:
 *
 *          使用STD
 *          重复数据读入
 *          int强制转ll
 *          重载工具函数
 *          启用debug输出
 *          关闭输入同步流
 *          使用文件输入流
 *          使用文件输出流
 *
 */

#define USE_STD

#define USE_LL

// #define REAP_READ
#define USE_TOOL

// #define USE_DEBUG
// #define USE_IOS
// #define IN_FILE "data.in"
// #define OUT_FILE "solve.out"

#ifdef USE_STD
using namespace std;
#endif

#ifdef USE_LL
#define int long long

#endif

// 辅助宏
#define rep(i, l, r) for (int i = (l); i < (r); i++)

#define _rep(i, l, r) for (int i = (l); i >= (r); i--)

#define all(x) (x).begin(), x.end()

#define endl '\n'  // 避免刷新缓冲区

#define inf32 0x3f3f3f3f

#define max32 INT_MAX


// 类型别名
using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128;
using pii = std::pair<int, int>;

// 常规输出
template <typename T>
void print(const T &t) {
    std::cout << t << endl;
}
template <typename T, typename... Args>
void print(const T &t, const Args... args) {
    std::cout << t << ' ';
    print(args...);
}

// USE_DEBUG 模式下的输出
template <typename T>
void debug(const T &t) {
#ifdef USE_DEBUG
    std::cout << t << "\n\n";
#endif
}
template <typename T, typename... Args>
void debug(const T &t, const Args... args) {
#ifdef USE_DEBUG
    std::cout << t << ' ';
    debug(args...);
#endif
}

#ifdef USE_TOOL
i64 ceilDiv(i64 n, i64 m) {
    if (n >= 0) {
        return (n + m - 1) / m;
    } else {
        return n / m;
    }
}

i64 floorDiv(i64 n, i64 m) {
    if (n >= 0) {
        return n / m;
    } else {
        return (n - m + 1) / m;
    }
}

template <class T>
void chmax(T &a, T b) {
    if (a < b) {
        a = b;
    }
}

template <class T>
void chmin(T &a, T b) {
    if (a > b) {
        a = b;
    }
}

i128 gcd(i128 a, i128 b) { return b ? gcd(b, a % b) : a; }
#endif

// 快读快写
int read();
void write(int);

const int N = 5e5 + 5;
const int MOD = 1e9 + 7;

void solve() {
    int n = read();
    int l = read(), d = read(), r = read(), u = read();
    vector<pii> p;
    p.push_back({ l, d });
    p.push_back({ l, u });
    p.push_back({ r, u });
    p.push_back({ r, d });
    int idx = -1;
    double v = inf32;
    rep(i, 0, n) {
        double x = read(), y = read();
        double dd = inf32;
        if (u >= y && d <= y) {
            chmin(dd, (double)min(abs(x - l), abs(x - r)));
        } else if (l <= x && r >= x) {
            chmin(dd, (double)min(abs(u - y), abs(d - y)));
        } else {
            rep(i, 0, 4) {
                double x1 = p[i].first, y1 = p[i].second;
                chmin(dd, sqrt((double)pow(x1 - x, 2) + pow(y1 - y, 2)));
            }
        }
        printf("%.9f ", dd);
        if (dd < v) {
            idx = i;
            v = dd;
        }
    }
    cout << endl;
    print(idx + 1);
}

signed main() {
    int T = 1;
    debug("hello world");
#ifdef IN_FILE
    freopen(IN_FILE, "r", stdin);
#endif

#ifdef OUT_FILE
    freopen(OUT_FILE, "w", stdout);
#endif

#ifdef REAP_READ
    std::cin >> T;
#endif

#ifdef USE_IOS
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
#endif

    while (T--) {
        solve();
    }
    return 0;
}

inline int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
inline void write(int x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
子任务 #1
Accepted
得分:100
测试点 #1
Accepted
得分:100
用时:4 ms
内存:268 KiB

输入文件(cow1.in

100
-33 3 -33 3
-15 -62
76 20
-43 73
-77 77
40 -54
-13 -12
-52 -25
-25 60
-50 -97
-81 -64
46 55
42 8
<606 bytes omitted>

答案文件(cow1.out

67.446274916 110.317722964 70.710678119 86.092973000 92.617492948 25.000000000 33.837848631 57.55866
<1233 bytes omitted>

用户输出

67.446274916 110.317722964 70.710678119 86.092973000 92.617492948 25.000000000 33.837848631 57.558665725 101.434708064 82.419657
<1205 bytes omitted>

系统信息

Exited with return code 0
测试点 #2
Accepted
得分:100
用时:3 ms
内存:356 KiB

输入文件(cow2.in

100
83 -62 83 -62
-100 -39
-85 39
38 -26
84 29
-53 66
91 100
83 77
62 84
-73 65
-6 88
-81 -67
-1 -4

<593 bytes omitted>

答案文件(cow2.out

184.439692041 196.022957839 57.628118137 91.005494340 186.761880479 162.197410584 139.000000000 147.
<1274 bytes omitted>

用户输出

184.439692041 196.022957839 57.628118137 91.005494340 186.761880479 162.197410584 139.000000000 147.502542351 201.159140980 174.
<1246 bytes omitted>

系统信息

Exited with return code 0
测试点 #3
Accepted
得分:100
用时:93 ms
内存:576 KiB

输入文件(cow3.in

100000
17 75 17 75
5 -5
-61 70
88 16
-25 -78
-72 -58
35 0
-40 66
36 26
-42 -86
21 17
44 93
-27 -58
6
<682143 bytes omitted>

答案文件(cow3.out

80.894993665 78.160092119 92.314679223 158.660013866 160.031246949 77.129760793 57.706152185 52.5547
<1350287 bytes omitted>

用户输出

80.894993665 78.160092119 92.314679223 158.660013866 160.031246949 77.129760793 57.706152185 52.554733374 171.470114014 58.13776
<1350259 bytes omitted>

系统信息

Exited with return code 0
测试点 #4
Accepted
得分:100
用时:102 ms
内存:468 KiB

输入文件(cow4.in

100000
43 -5 43 -5
-16 -70
56 67
26 21
22 58
-28 -51
-58 -92
-22 100
39 -13
82 -82
96 -20
-54 -23
-5
<683015 bytes omitted>

答案文件(cow4.out

87.783825389 73.164198895 31.064449134 66.407830864 84.599054368 133.304163476 123.490890352 8.94427
<1333958 bytes omitted>

用户输出

87.783825389 73.164198895 31.064449134 66.407830864 84.599054368 133.304163476 123.490890352 8.944271910 86.313382508 55.0817574
<1333930 bytes omitted>

系统信息

Exited with return code 0
测试点 #5
Accepted
得分:100
用时:4 ms
内存:356 KiB

输入文件(cow5.in

100
84 49 85 50
24 -6
33 39
50 97
0 -19
41 -21
10 5
21 -69
-72 95
-76 -12
90 34
-11 60
68 34
-73 88

<601 bytes omitted>

答案文件(cow5.out

81.394102980 51.971145841 58.008620049 108.074048689 82.152297594 86.092973000 133.764718816 162.360
<1261 bytes omitted>

用户输出

81.394102980 51.971145841 58.008620049 108.074048689 82.152297594 86.092973000 133.764718816 162.360709533 171.233758354 15.8113
<1233 bytes omitted>

系统信息

Exited with return code 0
测试点 #6
Accepted
得分:100
用时:3 ms
内存:280 KiB

输入文件(cow6.in

100
-15 -83 -14 -82
75 -99
-52 53
-10 2
49 34
6 67
37 -62
-74 -77
-41 -82
-74 0
-32 -5
-74 -52
59 -9
<599 bytes omitted>

答案文件(cow6.out

90.426765949 139.978569788 84.095184167 132.003787824 150.336289697 54.781383699 59.211485372 26.000
<1250 bytes omitted>

用户输出

90.426765949 139.978569788 84.095184167 132.003787824 150.336289697 54.781383699 59.211485372 26.000000000 101.019800039 78.8542
<1222 bytes omitted>

系统信息

Exited with return code 0
测试点 #7
Accepted
得分:100
用时:93 ms
内存:280 KiB

输入文件(cow7.in

100000
65 -59 66 -58
55 -6
-95 0
-31 -35
53 -71
-87 -30
59 61
-71 -72
73 50
-4 -75
63 -23
-10 36
-50
<682754 bytes omitted>

答案文件(cow7.out

52.952809179 170.188131196 98.716766560 16.970562748 154.557432691 119.151164493 136.619910701 108.2
<1356963 bytes omitted>

用户输出

52.952809179 170.188131196 98.716766560 16.970562748 154.557432691 119.151164493 136.619910701 108.226614102 70.830784268 35.057
<1356935 bytes omitted>

系统信息

Exited with return code 0
测试点 #8
Accepted
得分:100
用时:92 ms
内存:472 KiB

输入文件(cow8.in

100000
15 40 16 41
47 62
-53 -39
26 -37
-69 -99
64 -87
-79 34
6 30
-100 93
-72 -68
91 -1
-68 -53
71 
<682568 bytes omitted>

答案文件(cow8.out

37.443290454 104.235310716 77.646635471 162.409975063 135.768184786 94.191294715 13.453624047 126.21
<1334522 bytes omitted>

用户输出

37.443290454 104.235310716 77.646635471 162.409975063 135.768184786 94.191294715 13.453624047 126.210142223 138.683091976 85.475
<1334494 bytes omitted>

系统信息

Exited with return code 0
测试点 #9
Accepted
得分:100
用时:3 ms
内存:384 KiB

输入文件(cow9.in

100
-98 1 77 54
0 -54
12 99
-79 60
30 96
41 -47
-6 -48
89 -1
-99 -15
-91 -37
-19 -83
58 57
-21 -25
5
<627 bytes omitted>

答案文件(cow9.out

55.000000000 45.000000000 6.000000000 42.000000000 48.000000000 49.000000000 12.165525061 16.0312195
<1190 bytes omitted>

用户输出

55.000000000 45.000000000 6.000000000 42.000000000 48.000000000 49.000000000 12.165525061 16.031219542 38.000000000 84.000000000
<1162 bytes omitted>

系统信息

Exited with return code 0
测试点 #10
Accepted
得分:100
用时:77 ms
内存:476 KiB

输入文件(cow10.in

100000
13 68 92 96
-23 97
-31 -80
-61 -8
-70 40
-45 -11
43 25
21 43
-96 -28
-33 23
-50 -66
21 -60
37
<687140 bytes omitted>

答案文件(cow10.out

36.013886211 154.402072525 106.075444849 87.595661993 98.005101908 43.000000000 25.000000000 145.248
<1342024 bytes omitted>

用户输出

36.013886211 154.402072525 106.075444849 87.595661993 98.005101908 43.000000000 25.000000000 145.248063670 64.350602173 148.0709
<1341996 bytes omitted>

系统信息

Exited with return code 0