QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#172576 | #2432. Go with the Flow | PetroTarnavskyi | RE | 0ms | 0kb | C++17 | 2.0kb | 2023-09-09 19:48:37 | 2023-09-09 19:48:38 |
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) - 1; 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;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
int w, h;
int coor[4];
int f(int x, int y)
{
if (y == 0) return x;
if (x == w) return w + y;
if (y == h) return w + h + (w - x);
if (x == 0) return w + h + w + (h - y);
assert(0);
}
int getSide(int x)
{
return lower_bound(coor, coor + 4, x) - coor;
}
PII g(int x)
{
if (x < coor[0]) return {x, 0};
if (x < coor[1]) return {w, x - w};
if (x < coor[2]) return {w - (x - (coor[1])), h};
if (x < coor[3]) return {0, h - (x - coor[2])};
assert(0);
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed;
int n;
cin >> n >> w >> h;
w *= 2;
h *= 2;
coor[0] = w;
coor[1] = w + h;
coor[2] = w + h + w;
coor[3] = w + h + w + h;
vector<PII> v;
FOR (i, 0, n)
{
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
v.PB({f(x1 * 2, y1 * 2), i});
v.PB({f(x2 * 2, y2 * 2), i});
}
sort(ALL(v));
VI used(n, 0);
int l = 0;
FOR (r, 0, 2 * n)
{
while (l < r && used[v[r].S])
{
used[v[l++].S] = 0;
}
used[v[r].S] = 1;
if (r - l + 1 == n)
{
int c1 = v[l].F - 1;
int c2 = v[r].F + 1;
if (getSide(c1) == getSide(c2))
{
c2 = (coor[getSide(c2)] + 1) % (2 * (h + w));
}
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';
return 0;
}
}
w /= 2;
h /= 2;
cout << 2 << '\n';
cout << 0.5 << ' ' << 0 << ' ' << w - 0.5 << ' ' << h << '\n';
cout << 0 << ' ' << h - 0.5 << ' ' << w << ' ' << 0.5 << '\n';
return 0;
}
詳細信息
Test #1:
score: 0
Dangerous Syscalls