QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#568396#2434. Single Cut of FailurePoetryRE 117ms27084kbC++232.3kb2024-09-16 16:17:522024-09-16 16:17:52

Judging History

你现在查看的是最新测评结果

  • [2024-09-16 16:17:52]
  • 评测
  • 测评结果:RE
  • 用时:117ms
  • 内存:27084kb
  • [2024-09-16 16:17:52]
  • 提交

answer

#include <bits/stdc++.h>

using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;

using ld = long double;

int n, w, h;
struct Point {
    ld x;

    friend std::ostream &operator<<(std::ostream &os, Point k) {
        if (k.x < h) {
            return os << 0 << " " << k.x;
        } else if (k.x < h + w) {
            return os << k.x - h << " " << h;
        } else if (k.x < 2 * h + w) {
            return os << w << " " << h - (k.x - h - w);
        } else {
            return os << w - (k.x - 2 * h - w) << " " << 0;
        }
    }
} ;

struct Node {
    Point pos;
    int id, type;

    bool operator<(const Node &w) const {
        return pos.x < w.pos.x;
    }
} ;
std::vector<Node> a;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    std::cout.precision(10);
    std::cout << std::fixed;

    std::cin >> n >> w >> h;
    for (int i = 0; i < n; ++i) {
        int x0, y0, x1, y1;
        std::cin >> x0 >> y0 >> x1 >> y1;

        auto getpos = [&](int x, int y) {
            if (x == 0) {
                return y;
            }
            if (y == h) {
                return h + x;
            }
            if (x == w) {
                return h + w + (h - y);
            }
            return 2 * h + w + (w - x);
        } ;

        Point A{(ld)getpos(x0, y0)}, B{(ld)getpos(x1, y1)};
        if (A.x > B.x) {
            std::swap(A, B);
        }

        a.push_back({A, i, 0});
        a.push_back({B, i, 1});
    }

    a.push_back((Node){(Point){2.0 * h + 2 * w}, n, 1});
    sort(a.begin(), a.end());

    std::queue<Node> q;
    for (int i = 0; i < a.size(); ++i) {
        if (a[i].type == 1) {
            if (q.size() == n) {
                std::cout << 1 << "\n";
                std::cout << (Point){q.front().pos.x - 0.1} << " " << (Point){a[i].pos.x - 0.1} << "\n";
                return 0;
            }
            while (!q.empty() && q.front().id != a[i].id) {
                q.pop();
            }
            q.pop();
        }
        q.push(a[i]);
    }

    std::cout << 2 << "\n";
    std::cout << (Point){h - 0.1} << " " << (Point){2 * h + w - 0.1} << "\n";
    std::cout << (Point){0.1} << " " << (Point){h + w + 0.1} << "\n";

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3752kb

Test #2:

score: 0
Accepted
time: 0ms
memory: 4052kb

Test #3:

score: 0
Accepted
time: 0ms
memory: 3768kb

Test #4:

score: 0
Accepted
time: 0ms
memory: 4064kb

Test #5:

score: 0
Accepted
time: 0ms
memory: 3768kb

Test #6:

score: 0
Accepted
time: 0ms
memory: 3828kb

Test #7:

score: 0
Accepted
time: 0ms
memory: 3924kb

Test #8:

score: 0
Accepted
time: 0ms
memory: 3820kb

Test #9:

score: 0
Accepted
time: 92ms
memory: 27084kb

Test #10:

score: 0
Accepted
time: 94ms
memory: 26860kb

Test #11:

score: 0
Accepted
time: 117ms
memory: 27028kb

Test #12:

score: -100
Runtime Error