QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#829668#9770. Middle Pointorz_zWA 1ms3828kbC++147.2kb2024-12-24 11:57:332024-12-24 11:57:38

Judging History

This is the latest submission verdict.

  • [2024-12-24 11:57:38]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3828kb
  • [2024-12-24 11:57:33]
  • Submitted

answer

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
//#pragma GCC optimize("Ofast,fast-math")
//#pragma GCC target("avx,avx2")
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef double db;
#define F(i, a, b) for(int i = a; i <= (b); ++i)
#define F2(i, a, b) for(int i = a; i < (b); ++i)
#define dF(i, a, b) for(int i = a; i >= (b); --i)
template<typename T> void debug(string s, T x) {
	cerr << "[" << s << "] = [" << x << "]\n";
}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {
	for (int i = 0, b = 0; i < (int)s.size(); i++) if (s[i] == '(' || s[i] == '{') b++;
	else if (s[i] == ')' || s[i] == '}') b--;
	else if (s[i] == ',' && b == 0) {
		cerr << "[" << s.substr(0, i) << "] = [" << x << "] | ";
		debug(s.substr(s.find_first_not_of(' ', i + 1)), args...);
		break;
	}
}
#ifdef orzz
#define Debug(...) debug(#__VA_ARGS__, __VA_ARGS__)
#else
#define Debug(...)
#endif
#define pb push_back
#define fi first
#define se second
#define Mry fprintf(stderr, "%.3lf MB\n", (&Med - &Mbe) / 1048576.0)
#define Try cerr << 1e3 * clock() / CLOCKS_PER_SEC << " ms\n";
typedef long long ll;
// namespace Fread {const int SIZE = 1 << 17; char buf[SIZE], *S, *T; inline char getchar() {if (S == T) {T = (S = buf) + fread(buf, 1, SIZE, stdin); if (S == T) return '\n';} return *S++;}}
// namespace Fwrite {const int SIZE = 1 << 17; char buf[SIZE], *S = buf, *T = buf + SIZE; inline void flush() {fwrite(buf, 1, S - buf, stdout), S = buf;} inline void putchar(char c) {*S++ = c;if (S == T) flush();} struct NTR {~NTR() {flush();}} ztr;}
// #ifdef ONLINE_JUDGE
// #define getchar Fread::getchar
// #define putchar Fwrite::putchar
// #endif
inline int ri() {
	int x = 0;
	bool t = 0;
	char c = getchar();
	while (c < '0' || c > '9') t |= c == '-', c = getchar();
	while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
	return t ? -x : x;
}
inline void wi(int x) {
	if (x < 0) {
		putchar('-'), x = -x;
	}
	if (x > 9) wi(x / 10);
	putchar(x % 10 + 48);
}
inline void wi(int x, char s) {
	wi(x), putchar(s);
}
bool Mbe;
// mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3f;
const int _ = 2e5 + 5;

int A, B, X, Y;

map<int, int> nxtx, nxty;

vector<array<int, 4>> ans, cur;

map<pii, int> Nw;

void dfs(int lx, int rx, int ly, int ry) {
	Debug(lx, rx,ly,ry);
	int midx = (lx + rx) >> 1, midy = (ly + ry) >> 1;
	if(Nw.find({X, Y}) != Nw.end()) {
		if(ans.empty()) ans = cur;
		else if(ans.size() > cur.size()) ans = cur;
		return;
	}
	if(lx == X || rx == X) {
		if(Nw.find({X, ry}) != Nw.end() && Nw.find({X, ly}) != Nw.end()) {
			Nw[{X, midy}] = 1;
			cur.pb({X,ry,X,ly});
			if(Y < midy) {
				dfs(lx, rx, ly, midy);
			} else {
				dfs(lx, rx, midy, ry);
			}
			cur.pop_back();
			Nw.erase({X, midy});
		}
		return;
	}
	if(ly == Y || ry == Y) {
		if(Nw.find({lx, Y}) != Nw.end() && Nw.find({rx, Y}) != Nw.end()) {
			Nw[{midx, Y}] = 1;
			cur.pb({lx, Y,rx,Y});
			if(X < midx) {
				dfs(lx, midx, ly, ry);
			} else {
				dfs(midx, rx, ly, ry);
			}
			cur.pop_back();
			Nw.erase({midx, Y});
		}
		return;
	}
	int nlx = lx, nrx = rx, nly = ly, nry = ry;
	if(X < midx) nrx = midx;
	else nlx = midx;
	if(Y < midy) nry = midy;
	else nly = midy;
	Debug(nlx,nrx,nly,nry,midx,midy);
	// 两边一起跳
	if(Nw.find({lx, ly}) != Nw.end() && Nw.find({rx, ry}) != Nw.end() || Nw.find({lx, ry}) != Nw.end() && Nw.find({rx, ly}) != Nw.end()) {
		Nw[{midx, midy}] = 1;
		if(Nw.find({lx, ly}) != Nw.end() && Nw.find({rx, ry}) != Nw.end()) {
			cur.pb({lx,ly,rx,ry});
			dfs(nlx, nrx, nly, nry);
			cur.pop_back();
		} else {
			cur.pb({lx,ry,rx,ly});
			dfs(nlx, nrx, nly, nry);
			cur.pop_back();
		}
		Nw.erase({midx, midy});
	}
	if(Nw.find({lx, ly}) != Nw.end() && Nw.find({rx, ry}) != Nw.end() || Nw.find({lx, ry}) != Nw.end() && Nw.find({rx, ly}) != Nw.end()) {
		Nw[{midx, midy}] = 1;
		if(Nw.find({lx, ly}) != Nw.end() && Nw.find({rx, ry}) != Nw.end()) {
			cur.pb({lx,ly,rx,ry});
			dfs(nlx, nrx, nly, nry);
			cur.pop_back();
		} else {
			cur.pb({lx,ry,rx,ly});
			dfs(nlx, nrx, nly, nry);
			cur.pop_back();
		}
		Nw.erase({midx, midy});
	}
	if(Nw.find({lx, ly}) != Nw.end() && Nw.find({lx, ry}) != Nw.end()) {
		Nw[{lx, midy}] = 1;
		cur.pb({lx,ly,lx,ry});
		dfs(lx, rx, nly, nry);
		cur.pop_back();
		Nw.erase({lx, midy});
	}
	if(Nw.find({rx, ly}) != Nw.end() && Nw.find({rx, ry}) != Nw.end()) {
		Nw[{rx, midy}] = 1;
		cur.pb({rx,ly,rx,ry});
		dfs(lx, rx, nly, nry);
		cur.pop_back();
		Nw.erase({rx, midy});
	}
	if(Nw.find({lx, ly}) != Nw.end() && Nw.find({rx, ly}) != Nw.end()) {
		Nw[{midx, ly}] = 1;
		cur.pb({lx,ly,rx,ly});
		dfs(nlx, nrx, ly, ry);
		cur.pop_back();
		Nw.erase({midx, ly});
	}
	if(Nw.find({lx, ry}) != Nw.end() && Nw.find({rx, ry}) != Nw.end()) {
		Nw[{midx, ry}] = 1;
		cur.pb({lx,ry,rx,ry});
		dfs(nlx, nrx, ly, ry);
		cur.pop_back();
		Nw.erase({midx, ry});
	}
}

bool Med;
signed main() {
	// Mry;
	A = ri(), B = ri(), X = ri(), Y = ri();
	int l = 0, r = A, mid;
	int zk = 0;
	bool flg = 0;
	vector<pii> a;
	while(l <= r) {
		mid = (l + r) >> 1;
		if(X == 0 || X == A) {
			zk = 0;
			flg = 1;
			break;
		}
		if((l + r) & 1) {
			break;
		}
		zk++;
		a.pb({l, r});
		if(mid > X) r = mid;
		else l = mid;
		if(mid == X) {
			flg = 1;
			break;
		}
	}
	if(!flg) {
		puts("-1");
		return 0;
	}
	l = 0, r = B;
	int zk2 = 0;
	flg = 0;
	vector<pii> b;
	while(l <= r) {
		mid = (l + r) >> 1;
		if(Y == 0 || Y == B) {
			zk2 = 0;
			flg = 1;
			break;
		}
		if((l + r) & 1) {
			break;
		}
		zk2++;
		b.pb({l, r});
		if(mid > Y) r = mid;
		else l = mid;
		if(mid == Y) {
			flg = 1;
			break;
		}
	}
	if(!flg) {
		puts("-1");
		return 0;
	}
	if(zk > 5 && zk2 > 5) {
		if(a.size() < b.size()) {
			cout << a.size() + a.size() + b.size() << '\n';
			for(pii v : a) {
				cout << v.fi << ' ' << 0 << ' ' << v.se << ' ' << 0 << '\n';
			}
			for(pii v : a) {
				cout << v.fi << ' ' << B << ' ' << v.se << ' ' << B << '\n';
			}
			for(pii v : b) {
				cout << X << ' ' << v.fi << ' ' << X << ' ' << v.se << '\n';
			}
		} else {
			cout << b.size() + b.size() + a.size() << '\n';
			for(pii v : b) {
				cout << 0 << ' ' << v.fi << ' ' << 0 << ' ' << v.se << '\n';
			}
			for(pii v : b) {
				cout << A << ' ' << v.fi << ' ' << A << ' ' << v.se << '\n';
			}
			for(pii v : a) {
				cout << v.fi << ' ' << Y << ' ' << v.se << ' ' << Y << '\n';
			}
		}
		return 0;
	}
	Nw[{0, 0}] = Nw[{A, 0}] = Nw[{0, B}] = Nw[{A, B}] = 1;
	if(Nw.find({X, Y}) != Nw.end()) {
		cout << 0 << '\n';
		return 0;
	}
	dfs(0, A, 0, B);
	Debug(ans.size());
	cout << ans.size() << '\n';
	for(auto v : ans) {
		cout<< v[0]<<' '<<v[1]<<' '<<v[2]<<' '<<v[3] <<'\n';
	}
	// Try;
	return 0;
}

/*
2 2
1 1

8 8
5 0

2024 0
1012 0

2024 2024
2023 2023

8 6
7 3

*/

詳細信息

Test #1:

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

input:

2 2
1 1

output:

1
0 0 2 2

result:

ok correct!

Test #2:

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

input:

8 8
5 0

output:

3
0 0 8 0
4 0 8 0
4 0 6 0

result:

ok correct!

Test #3:

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

input:

0 0
0 0

output:

0

result:

ok correct!

Test #4:

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

input:

2024 0
1012 0

output:

1
0 0 2024 0

result:

ok correct!

Test #5:

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

input:

2024 2024
2023 2023

output:

-1

result:

ok correct!

Test #6:

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

input:

8 6
7 3

output:

3
0 0 8 0
4 0 8 0
6 0 8 6

result:

ok correct!

Test #7:

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

input:

2024 2026
2024 2026

output:

0

result:

ok correct!

Test #8:

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

input:

1000000000 1000000000
70 0

output:

-1

result:

ok correct!

Test #9:

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

input:

3 6
2 4

output:

-1

result:

ok correct!

Test #10:

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

input:

7 7
7 2

output:

-1

result:

ok correct!

Test #11:

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

input:

6 2
5 2

output:

-1

result:

ok correct!

Test #12:

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

input:

5 7
5 5

output:

-1

result:

ok correct!

Test #13:

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

input:

4 7
2 3

output:

-1

result:

ok correct!

Test #14:

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

input:

8 2
2 2

output:

2
0 2 8 2
0 2 4 2

result:

ok correct!

Test #15:

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

input:

3 3
0 2

output:

-1

result:

ok correct!

Test #16:

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

input:

7 7
1 4

output:

-1

result:

ok correct!

Test #17:

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

input:

6 3
6 1

output:

-1

result:

ok correct!

Test #18:

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

input:

4 2
2 1

output:

1
0 0 4 2

result:

ok correct!

Test #19:

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

input:

7 2
3 2

output:

-1

result:

ok correct!

Test #20:

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

input:

2 7
0 3

output:

-1

result:

ok correct!

Test #21:

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

input:

1 7
1 0

output:

0

result:

ok correct!

Test #22:

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

input:

5 1
0 0

output:

0

result:

ok correct!

Test #23:

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

input:

8 7
4 3

output:

-1

result:

ok correct!

Test #24:

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

input:

180057652 674822131
110693180 428023738

output:

-1

result:

ok correct!

Test #25:

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

input:

62347541 812142018
42922107 486416913

output:

-1

result:

ok correct!

Test #26:

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

input:

239604722 244429197
78993837 108804105

output:

-1

result:

ok correct!

Test #27:

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

input:

416861903 381749084
375027630 373683256

output:

-1

result:

ok correct!

Test #28:

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

input:

594119084 519068971
429116021 298715088

output:

-1

result:

ok correct!

Test #29:

score: -100
Wrong Answer
time: 0ms
memory: 3796kb

input:

536870912 536870912
233225286 372408647

output:

85
0 0 536870912 0
0 0 268435456 0
134217728 0 268435456 0
201326592 0 268435456 0
201326592 0 234881024 0
218103808 0 234881024 0
226492416 0 234881024 0
230686720 0 234881024 0
232783872 0 234881024 0
232783872 0 233832448 0
232783872 0 233308160 0
233046016 0 233308160 0
233177088 0 233308160 0
2...

result:

wrong answer Jury has a better answer