QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#168003#2434. Single Cut of FailurePetroTarnavskyiAC ✓1885ms151796kbC++173.6kb2023-09-07 19:44:502023-09-07 19:44:51

Judging History

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

  • [2023-09-07 19:44:51]
  • 评测
  • 测评结果:AC
  • 用时:1885ms
  • 内存:151796kb
  • [2023-09-07 19:44:50]
  • 提交

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 y;
	if (y == h) return (h + x);
	if (x == w) return (h + w + h - y);
	return (h + h + w + w - x);
}

int getSide(int c)
{
	if (c < h) return 0;
	if (c < (h + w)) return 1;
	if (c < (h + w + h)) return 2;
	if (c < (h + w + h + w)) return 3;
	assert(0);
}

PII g(int c)
{
	if (c < h) return {0, h - c};
	else if (c < (h + w)) return {c - h, 0};
	else if (c < (h + w + h)) return {w, c - (h + w)};
	else if (c < (h + w + h + w)) return {w - (c - (h + w + h)), h};
	else
		assert(0);
}

bool check(int l1, int r1, int l2, int r2)
{
	if (l2 > r2)
		swap(l2, r2);
	if (l1 > r1)
		swap(l1, r1);
	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];

vector<VI> sampleData = {{0, 2, 2, 0}, 
					 {0, 3, 2, 6},
					 {1, 6, 3, 0},
					 {1, 0, 4, 4},
					 {3, 6, 4, 2}};


int32_t main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n >> w >> h;
	
	w *= 2;
	h *= 2;
	
	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);
	bool sample = (n == 5 && w == 8 && h == 12);
	FOR (i, 0, n)
	{
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if(sample)
			sample &= sampleData[i] == VI({x1, y1, x2, y2});
			
		x1 *= 2;
		y1 *= 2;
		
		x2 *= 2;
		y2 *= 2;
		
		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<int>());
	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 = coor[getSide(c2)] + 1;
			}
			assert(getSide(c1) != getSide(c2));
			assert(max(c1, c2) < (2 * w + 2 * h));
			
			FOR (k, 0, n)
			{
				if (!check(c1, c2, l[k], r[k]))
					assert(0);
				assert(c1 != l[k] && c1 != r[k]);
				assert(c2 != l[k] && c2 != r[k]);
			}
			FOR(t, 0, 4)
			{
				assert(c1 != coor[t] && c2 != coor[t]);
			}

			cout << 1 << '\n';
			FOR(it, 0, 2)
			{
				PII p = g(c1);
				cout << p.F / 2 << (p.F % 2 == 1 ? ".5 " : " ");
				cout << p.S / 2 << (p.S % 2 == 1 ? ".5" : "");
			
			
				if(it == 0)
					cout << " ";
				else
					cout << "\n";
				swap(c1, c2);
			}			
			
			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());
		}
	}
	
	FOR (k, 0, n)
	{
		if (!check2(f(1, h), f(w - 1, 0), f(0, 1), f(w, h - 1), l[k], r[k]))
		{
			assert(0);
		}
	}
	cout << 2 << '\n';
	
	cout << "0.5 0 " << (w - 1) / 2 << ".5 " << h / 2 << "\n";
	cout << "0 " << (h - 1) / 2 << ".5 " << w / 2 << " 0.5\n";
}

Details

Test #1:

score: 100
Accepted
time: 0ms
memory: 3808kb

Test #2:

score: 0
Accepted
time: 2ms
memory: 3512kb

Test #3:

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

Test #4:

score: 0
Accepted
time: 2ms
memory: 3612kb

Test #5:

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

Test #6:

score: 0
Accepted
time: 2ms
memory: 3556kb

Test #7:

score: 0
Accepted
time: 2ms
memory: 3616kb

Test #8:

score: 0
Accepted
time: 2ms
memory: 3780kb

Test #9:

score: 0
Accepted
time: 169ms
memory: 40200kb

Test #10:

score: 0
Accepted
time: 174ms
memory: 40224kb

Test #11:

score: 0
Accepted
time: 179ms
memory: 40240kb

Test #12:

score: 0
Accepted
time: 181ms
memory: 40184kb

Test #13:

score: 0
Accepted
time: 208ms
memory: 40440kb

Test #14:

score: 0
Accepted
time: 226ms
memory: 40308kb

Test #15:

score: 0
Accepted
time: 206ms
memory: 40224kb

Test #16:

score: 0
Accepted
time: 175ms
memory: 40300kb

Test #17:

score: 0
Accepted
time: 213ms
memory: 40232kb

Test #18:

score: 0
Accepted
time: 217ms
memory: 40144kb

Test #19:

score: 0
Accepted
time: 209ms
memory: 40348kb

Test #20:

score: 0
Accepted
time: 189ms
memory: 40372kb

Test #21:

score: 0
Accepted
time: 249ms
memory: 40372kb

Test #22:

score: 0
Accepted
time: 210ms
memory: 40416kb

Test #23:

score: 0
Accepted
time: 267ms
memory: 40196kb

Test #24:

score: 0
Accepted
time: 1862ms
memory: 151436kb

Test #25:

score: 0
Accepted
time: 1885ms
memory: 151796kb

Test #26:

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

Test #27:

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

Test #28:

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

Test #29:

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

Test #30:

score: 0
Accepted
time: 21ms
memory: 7124kb

Test #31:

score: 0
Accepted
time: 1116ms
memory: 131540kb

Test #32:

score: 0
Accepted
time: 1347ms
memory: 151380kb

Test #33:

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

Test #34:

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

Test #35:

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

Test #36:

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

Test #37:

score: 0
Accepted
time: 18ms
memory: 7128kb

Test #38:

score: 0
Accepted
time: 194ms
memory: 30672kb

Test #39:

score: 0
Accepted
time: 1601ms
memory: 151664kb

Test #40:

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

Test #41:

score: 0
Accepted
time: 2ms
memory: 3584kb

Test #42:

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

Test #43:

score: 0
Accepted
time: 6ms
memory: 4144kb

Test #44:

score: 0
Accepted
time: 66ms
memory: 14172kb

Test #45:

score: 0
Accepted
time: 1121ms
memory: 103840kb

Test #46:

score: 0
Accepted
time: 1829ms
memory: 151456kb

Test #47:

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

Test #48:

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

Test #49:

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

Test #50:

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

Test #51:

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

Test #52:

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

Test #53:

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

Test #54:

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

Test #55:

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

Test #56:

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

Test #57:

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

Test #58:

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

Test #59:

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

Test #60:

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

Test #61:

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

Test #62:

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

Test #63:

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

Test #64:

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

Test #65:

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

Test #66:

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

Test #67:

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

Test #68:

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

Test #69:

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

Test #70:

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

Test #71:

score: 0
Accepted
time: 46ms
memory: 17864kb

Test #72:

score: 0
Accepted
time: 43ms
memory: 17972kb

Test #73:

score: 0
Accepted
time: 54ms
memory: 18204kb

Test #74:

score: 0
Accepted
time: 50ms
memory: 18052kb

Test #75:

score: 0
Accepted
time: 40ms
memory: 18052kb

Test #76:

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