QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#165606 | #2434. Single Cut of Failure | PetroTarnavskyi# | WA | 1ms | 3788kb | C++17 | 2.9kb | 2023-09-05 19:50:13 | 2023-09-05 19:50:14 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define FILL(a, b) memset(a, b, sizeof(a))
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
#define int LL
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
int w, h;
int f(int x, int y)
{
if (x == 0) return 2 * y;
if (y == h) return 2 * (h + x);
if (x == w) return 2 * (h + w + h - y);
return 2 * (h + h + w + w - x);
}
int getSide(int c)
{
if (c < 2 * h) return 0;
if (c < 2 * (h + w)) return 1;
if (c < 2 * (h + w + h)) return 2;
if (c < 2 * (h + w + h + w)) return 3;
assert(0);
}
PII g(int c)
{
if (c < 2 * h) return {0, 2 * h - c};
else if (c < 2 * (h + w)) return {c - 2 * h, 0};
else if (c < 2 * (h + w + h)) return {2 * w, c - 2 * (h + w)};
else if (c < 2 * (h + w + h + w)) return {2 * w - (c - 2 * (h + w + h)), 2 * h};
else
assert(0);
}
bool check(int l1, int r1, int l2, int r2)
{
if (l2 > r2)
swap(l2, r2);
return (l1 < l2 && r1 < r2 && l2 < r1) || (l2 < l1 && r2 < r1 && l1 < r2);
}
bool check2(int l1, int r1, int l2, int r2, int l3, int r3)
{
return check(l1, r1, l3, r3) || check(l2, r2, l3, r3);
}
int coor[4];
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n >> w >> h;
coor[0] = h;
coor[1] = h + w;
coor[2] = h + w + h;
coor[3] = 0;
vector<PII> v(2 * n);
vector<VI> mn(n);
VI l(n), r(n);
FOR (i, 0, n)
{
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
y1 = h - y1;
y2 = h - y2;
l[i] = f(x1, y1);
r[i] = f(x2, y2);
v[2 * i] = {l[i], i};
v[2 * i + 1] = {r[i], i};
}
sort(ALL(v));
FOR (i, 0, 2 * n)
{
mn[v[i].S].PB(i);
}
FOR (i, 0, n)
sort(ALL(mn[i]), greater());
set<int> mnpos;
FOR (i, 0, n)
mnpos.insert(mn[i].back());
FOR (i, 0, 2 * n)
{
if (*mnpos.rbegin() - i == n - 1)
{
int c1 = v[i].F - 1;
int c2 = v[i + n - 1].F + 1;
assert(c1 < c2);
if (getSide(c1) == getSide(c2))
{
assert(c1 < c2);
c2 = 2 * coor[getSide(c2)] + 1;
}
cout << 1 << '\n';
PII p = g(c1);
cout << p.F / 2.0 << ' ' << p.S / 2.0 << ' ';
p = g(c2);
cout << p.F / 2.0 << ' ' << p.S / 2.0 << '\n';
FOR (k, 0, n)
{
if (!check(c1, c2, l[k], r[k]))
assert(0);
}
return 0;
}
else
{
int j = v[i].S;
mnpos.erase(mn[j].back());
mn[j].pop_back();
if (mn[j].empty())
break;
mnpos.insert(mn[j].back());
}
}
cout << 2 << '\n';
//FOR (k, 0, n)
//{
// if (check2(f(1, 2 * h), f(2 * w - 1, 0), f(0, 1), f(w * 2, 2 * h - 1), l[k], r[k]))
// assert(0);
//}
cout << 0.5 << ' ' << 0 << ' ' << w - 0.5 << ' ' << h << '\n';
cout << 0 << ' ' << h - 0.5 << ' ' << w << ' ' << 0.5 << '\n';
}
Details
Test #1:
score: 100
Accepted
time: 0ms
memory: 3724kb
Test #2:
score: 0
Accepted
time: 1ms
memory: 3772kb
Test #3:
score: 0
Accepted
time: 1ms
memory: 3576kb
Test #4:
score: 0
Accepted
time: 1ms
memory: 3692kb
Test #5:
score: 0
Accepted
time: 0ms
memory: 3736kb
Test #6:
score: 0
Accepted
time: 1ms
memory: 3788kb
Test #7:
score: -100
Wrong Answer
time: 0ms
memory: 3604kb