QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#172580#2434. Single Cut of FailurePetroTarnavskyiAC ✓395ms22832kbC++172.0kb2023-09-09 19:49:422023-09-09 19:49:43

Judging History

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

  • [2023-09-09 19:49:43]
  • 评测
  • 测评结果:AC
  • 用时:395ms
  • 内存:22832kb
  • [2023-09-09 19:49:42]
  • 提交

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;
}

Details

Test #1:

score: 100
Accepted
time: 1ms
memory: 3952kb

Test #2:

score: 0
Accepted
time: 1ms
memory: 4048kb

Test #3:

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

Test #4:

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

Test #5:

score: 0
Accepted
time: 1ms
memory: 3980kb

Test #6:

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

Test #7:

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

Test #8:

score: 0
Accepted
time: 1ms
memory: 3824kb

Test #9:

score: 0
Accepted
time: 78ms
memory: 8340kb

Test #10:

score: 0
Accepted
time: 71ms
memory: 8100kb

Test #11:

score: 0
Accepted
time: 74ms
memory: 9044kb

Test #12:

score: 0
Accepted
time: 96ms
memory: 7952kb

Test #13:

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

Test #14:

score: 0
Accepted
time: 99ms
memory: 8152kb

Test #15:

score: 0
Accepted
time: 91ms
memory: 8284kb

Test #16:

score: 0
Accepted
time: 90ms
memory: 8804kb

Test #17:

score: 0
Accepted
time: 90ms
memory: 8132kb

Test #18:

score: 0
Accepted
time: 80ms
memory: 8972kb

Test #19:

score: 0
Accepted
time: 96ms
memory: 8708kb

Test #20:

score: 0
Accepted
time: 87ms
memory: 7920kb

Test #21:

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

Test #22:

score: 0
Accepted
time: 88ms
memory: 8108kb

Test #23:

score: 0
Accepted
time: 79ms
memory: 8128kb

Test #24:

score: 0
Accepted
time: 368ms
memory: 22728kb

Test #25:

score: 0
Accepted
time: 381ms
memory: 22692kb

Test #26:

score: 0
Accepted
time: 1ms
memory: 3824kb

Test #27:

score: 0
Accepted
time: 1ms
memory: 4060kb

Test #28:

score: 0
Accepted
time: 1ms
memory: 3864kb

Test #29:

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

Test #30:

score: 0
Accepted
time: 5ms
memory: 3948kb

Test #31:

score: 0
Accepted
time: 318ms
memory: 21496kb

Test #32:

score: 0
Accepted
time: 373ms
memory: 22728kb

Test #33:

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

Test #34:

score: 0
Accepted
time: 1ms
memory: 3824kb

Test #35:

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

Test #36:

score: 0
Accepted
time: 4ms
memory: 4016kb

Test #37:

score: 0
Accepted
time: 7ms
memory: 3984kb

Test #38:

score: 0
Accepted
time: 55ms
memory: 8788kb

Test #39:

score: 0
Accepted
time: 395ms
memory: 22636kb

Test #40:

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

Test #41:

score: 0
Accepted
time: 1ms
memory: 3824kb

Test #42:

score: 0
Accepted
time: 1ms
memory: 4076kb

Test #43:

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

Test #44:

score: 0
Accepted
time: 25ms
memory: 5336kb

Test #45:

score: 0
Accepted
time: 257ms
memory: 19764kb

Test #46:

score: 0
Accepted
time: 369ms
memory: 22832kb

Test #47:

score: 0
Accepted
time: 1ms
memory: 3832kb

Test #48:

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

Test #49:

score: 0
Accepted
time: 1ms
memory: 3988kb

Test #50:

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

Test #51:

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

Test #52:

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

Test #53:

score: 0
Accepted
time: 1ms
memory: 3836kb

Test #54:

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

Test #55:

score: 0
Accepted
time: 1ms
memory: 3952kb

Test #56:

score: 0
Accepted
time: 1ms
memory: 3948kb

Test #57:

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

Test #58:

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

Test #59:

score: 0
Accepted
time: 1ms
memory: 3756kb

Test #60:

score: 0
Accepted
time: 1ms
memory: 3764kb

Test #61:

score: 0
Accepted
time: 1ms
memory: 3856kb

Test #62:

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

Test #63:

score: 0
Accepted
time: 1ms
memory: 3824kb

Test #64:

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

Test #65:

score: 0
Accepted
time: 1ms
memory: 3824kb

Test #66:

score: 0
Accepted
time: 1ms
memory: 3980kb

Test #67:

score: 0
Accepted
time: 1ms
memory: 3824kb

Test #68:

score: 0
Accepted
time: 1ms
memory: 3984kb

Test #69:

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

Test #70:

score: 0
Accepted
time: 1ms
memory: 3956kb

Test #71:

score: 0
Accepted
time: 19ms
memory: 5184kb

Test #72:

score: 0
Accepted
time: 17ms
memory: 5360kb

Test #73:

score: 0
Accepted
time: 28ms
memory: 5272kb

Test #74:

score: 0
Accepted
time: 29ms
memory: 5360kb

Test #75:

score: 0
Accepted
time: 28ms
memory: 5228kb

Test #76:

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