QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#568310 | #2434. Single Cut of Failure | Poetry | WA | 0ms | 4064kb | C++23 | 2.2kb | 2024-09-16 16:00:56 | 2024-09-16 16:00:56 |
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::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 * 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;
}
Details
Test #1:
score: 100
Accepted
time: 0ms
memory: 3824kb
Test #2:
score: 0
Accepted
time: 0ms
memory: 3764kb
Test #3:
score: 0
Accepted
time: 0ms
memory: 3860kb
Test #4:
score: 0
Accepted
time: 0ms
memory: 4064kb
Test #5:
score: 0
Accepted
time: 0ms
memory: 3948kb
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3884kb