QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#568396 | #2434. Single Cut of Failure | Poetry | RE | 117ms | 27084kb | C++23 | 2.3kb | 2024-09-16 16:17:52 | 2024-09-16 16:17:52 |
Judging History
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