QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#824502#9770. Middle Point新月争霸 (Jiaming Lin, Jingqi Wan, Jun Yin)#WA 1ms4064kbC++143.5kb2024-12-21 14:27:392024-12-21 14:27:47

Judging History

This is the latest submission verdict.

  • [2024-12-21 14:27:47]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 4064kb
  • [2024-12-21 14:27:39]
  • Submitted

answer

//Linkwish's code
#include<bits/stdc++.h>
#define endl '\n'
#define si static inline
#define mp make_pair
#define fi first
#define se second
using namespace std;typedef long long ll;typedef __int128 li;
typedef long double ld;
typedef pair<int,int> pii;typedef pair<ll,ll> pll;typedef const int ci;
typedef const ll cl;const int iinf=INT_MAX;const ll linf=LLONG_MAX;
template<typename T>si bool gmax(T &x,const T y){if(x<y)return x=y,1;return 0;}
template<typename T>si bool gmin(T &x,const T y){if(y<x)return x=y,1;return 0;}

namespace LinkWish{

	void mian(){
		int n, m, x, y; scanf("%d %d %d %d", &n, &m, &x, &y);
		if (n == 0) {
			if (m == 0) puts("0");
			else {
				int mm = 0; while (m % 2 == 0) m /= 2, mm++;
				if (y % m) puts("-1");
				else {
					y /= m; int M = m, N = 1;m = 1 << mm;
					int d = 0; while (d < mm && y % 2 == 0) y /= 2, d++;
					int f = mm - d; vector<int> ops[2];
					for (int i = 0; i < f; i++) ops[0].push_back(0);
					for (int i = 0; i < f; i++) ops[1].push_back(y >> i & 1);
					//printf("%d\n", f);
					int sx = 0, sy = 0; printf("%d\n", f);
					for (int i = 0; i < f; i++) {
						int tx = ops[0][i] ? n : 0, ty = ops[1][i] ? m : 0;
						printf("%d %d %d %d\n", sx * N, sy * M,tx * N, ty* M);
						sx = (sx + tx) / 2;
						sy = (sy + ty) / 2;
					}
				}
			}
		}
		else {
			if (m == 0) {
				swap(n, m); swap(x, y);
				int mm = 0; while (m % 2 == 0) m /= 2, mm++;
				if (y % m) puts("-1");
				else {
					y /= m; int M = m, N = 1;m = 1 << mm;
					int d = 0; while (d < mm && y % 2 == 0) y /= 2, d++;
					int f = mm - d; vector<int> ops[2];
					for (int i = 0; i < f; i++) ops[0].push_back(0);
					for (int i = 0; i < f; i++) ops[1].push_back(y >> i & 1);
					//printf("%d\n", f);
					int sx = 0, sy = 0; printf("%d\n", f);
					for (int i = 0; i < f; i++) {
						int tx = ops[0][i] ? n : 0, ty = ops[1][i] ? m : 0;
						printf("%d %d %d %d\n", ty* M,tx * N, sy * M, sx * N);
						sx = (sx + tx) / 2;
						sy = (sy + ty) / 2;
					}
				}
			}
			else {
				int nn = 0, mm = 0, xx = 0, yy = 0;
				while (n % 2 == 0) n /= 2, nn++;
				while (m % 2 == 0) m /= 2, mm++;
				if (x % n || y % m) puts("-1");
				else {
					x /= n; y /= m; int N = n, M = m;
					n = 1 << nn; m = 1 << mm;
					//printf("%d %d %d %d\n", n, m, x, y);
					while (xx < nn && (x >> (xx + 1) << (xx + 1)) == x) xx++;
					while (yy < mm && (y >> (yy + 1) << (yy + 1)) == y) yy++;
					int dx = nn - xx, dy = mm - yy;
					//printf("dxdy %d %d\n", dx, dy);
					// nn - xx max(dx, dy)
					x >>= xx; x <<= max(dx, dy) - dx;
					y >>= yy; y <<= max(dx, dy) - dy; 
					//printf("xy %d %d\n", x, y);
					vector<int> ops[2];
					for (int i = 0; i < max(dx, dy); i++) if (x >> i & 1) ops[0].push_back(1); else ops[0].push_back(0);
					for (int i = 0; i < max(dx, dy); i++) if (y >> i & 1) ops[1].push_back(1); else ops[1].push_back(0);
					//for (int x : ops[1]) printf("%d\n", x);
					//if (dx <= dy) {
						
					//}
					int sx = 0, sy = 0; printf("%d\n", max(dx, dy));
					for (int i = 0; i < max(dx, dy); i++) {
						int tx = ops[0][i] ? n : 0, ty = ops[1][i] ? m : 0;
						printf("%d %d %d %d\n", sx * N, sy * M,tx * N, ty* M);
						sx = (sx + tx) / 2;
						sy = (sy + ty) / 2;
					}
				} 
			}
		}
	}
}

signed main(){
	#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	LinkWish::mian();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2 2
1 1

output:

1
0 0 2 2

result:

ok correct!

Test #2:

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

input:

8 8
5 0

output:

3
0 0 8 0
4 0 0 0
2 0 8 0

result:

ok correct!

Test #3:

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

input:

0 0
0 0

output:

0

result:

ok correct!

Test #4:

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

input:

2024 0
1012 0

output:

1
2024 0 0 0

result:

ok correct!

Test #5:

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

input:

2024 2024
2023 2023

output:

-1

result:

ok correct!

Test #6:

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

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: 3860kb

input:

2024 2026
2024 2026

output:

0

result:

ok correct!

Test #8:

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

input:

1000000000 1000000000
70 0

output:

-1

result:

ok correct!

Test #9:

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

input:

3 6
2 4

output:

-1

result:

ok correct!

Test #10:

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

input:

7 7
7 2

output:

-1

result:

ok correct!

Test #11:

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

input:

6 2
5 2

output:

-1

result:

ok correct!

Test #12:

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

input:

5 7
5 5

output:

-1

result:

ok correct!

Test #13:

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

input:

4 7
2 3

output:

-1

result:

ok correct!

Test #14:

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

input:

8 2
2 2

output:

2
0 0 8 0
4 0 0 0

result:

wrong answer target point have not been added into S