QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#824936#9770. Middle Pointucup-team3691#WA 1ms3828kbC++233.0kb2024-12-21 16:36:542024-12-21 16:36:54

Judging History

This is the latest submission verdict.

  • [2024-12-21 16:36:54]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3828kb
  • [2024-12-21 16:36:54]
  • Submitted

answer

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <stack>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

const int maxVal = 70;

void computeMoves(int st, int dr, int val, vector <pair <int, int>> &moves) {
    if (val == st || val == dr) {
        return;
    }
    while (st <= dr) {
        int mij = (st + dr) / 2;
        moves.push_back({st, dr});
        if (mij == val) {
            return;
        }
        if (val < mij) {
            dr = mij;
        } else {
            st = mij;
        }
    }
}

int calcMin(int a) {
    while (a % 2 == 0) {
        a /= 2;
    }
    return a;
}

void solveY(int x, int y, int b) {
    if (y == 0 || y == b) {
        cout << "0\n";
        return;
    }
    if (y % calcMin(b) != 0) {
        cout << "-1\n";
        return;
    }
    vector <pair <int, int>> yMoves;
    computeMoves(0, b, y, yMoves);

    cout << yMoves.size() << '\n';
    for (auto p : yMoves) {
        cout << x << ' ' << p.first << ' ' << x << ' ' << p.second << '\n';
    }
}

void solveX(int x, int y, int a) {
    if (x % calcMin(a) != 0) {
        cout << "-1\n";
        return;
    }
    vector <pair <int, int>> xMoves;
    computeMoves(0, a, x, xMoves);

    cout << xMoves.size() << '\n';
    for (auto p : xMoves) {
        cout << p.first << ' ' << y << ' ' << p.second << ' ' << y << '\n';
    }
}


void solve() {
    int a, b;
    int x, y;
    cin >> a >> b;
    cin >> x >> y;
    if (x == 0 || x == a) {
        solveY(x, y, b);
        return;
    }
    if (y == 0 || y == b) {
        solveX(x, y, a);
        return;
    }
    int minA = calcMin(a), minB = calcMin(b);
    if (x % minA != 0 || y % minB != 0) {
        cout << "-1\n";
        return;
    }
    vector <pair <int, int>> xMoves, yMoves;
    computeMoves(0, a, x, xMoves);
    computeMoves(0, b, y, yMoves);
    reverse(xMoves.begin(), xMoves.end());
    reverse(yMoves.begin(), yMoves.end());
    while (xMoves.size() < yMoves.size()) {
        xMoves.push_back({0, 0});
    }
    while (yMoves.size() < xMoves.size()) {
        yMoves.push_back({0, 0});
    }
    reverse(xMoves.begin(), xMoves.end());
    reverse(yMoves.begin(), yMoves.end());
    cout << xMoves.size() << '\n';
    for (int i = 0; i < xMoves.size(); i++) {
        auto px = xMoves[i];
        auto py = yMoves[i];
        cout << px.first << ' ' << py.first << ' ' << px.second << ' ' << py.second << '\n';
    }
}


signed main() {
#ifdef LOCAL
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
#endif // LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int nrt = 1;
    //cin >> nrt;
    for (int t = 1; t <= nrt; t++) {
        solve();
    }
    return 0;
}

详细

Test #1:

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

input:

2 2
1 1

output:

1
0 0 2 2

result:

ok correct!

Test #2:

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

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

input:

0 0
0 0

output:

0

result:

ok correct!

Test #4:

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

input:

2024 0
1012 0

output:

1
0 0 2024 0

result:

ok correct!

Test #5:

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

input:

2024 2024
2023 2023

output:

-1

result:

ok correct!

Test #6:

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

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: 1ms
memory: 3820kb

input:

2024 2026
2024 2026

output:

0

result:

ok correct!

Test #8:

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

input:

1000000000 1000000000
70 0

output:

-1

result:

ok correct!

Test #9:

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

input:

3 6
2 4

output:

-1

result:

ok correct!

Test #10:

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

input:

7 7
7 2

output:

-1

result:

ok correct!

Test #11:

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

input:

6 2
5 2

output:

-1

result:

ok correct!

Test #12:

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

input:

5 7
5 5

output:

-1

result:

ok correct!

Test #13:

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

input:

4 7
2 3

output:

-1

result:

ok correct!

Test #14:

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

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

input:

3 3
0 2

output:

-1

result:

ok correct!

Test #16:

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

input:

7 7
1 4

output:

-1

result:

ok correct!

Test #17:

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

input:

6 3
6 1

output:

-1

result:

ok correct!

Test #18:

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

input:

4 2
2 1

output:

1
0 0 4 2

result:

ok correct!

Test #19:

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

input:

7 2
3 2

output:

-1

result:

ok correct!

Test #20:

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

input:

2 7
0 3

output:

-1

result:

ok correct!

Test #21:

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

input:

1 7
1 0

output:

0

result:

ok correct!

Test #22:

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

input:

5 1
0 0

output:

0

result:

ok correct!

Test #23:

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

input:

8 7
4 3

output:

-1

result:

ok correct!

Test #24:

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

input:

180057652 674822131
110693180 428023738

output:

-1

result:

ok correct!

Test #25:

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

input:

62347541 812142018
42922107 486416913

output:

-1

result:

ok correct!

Test #26:

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

input:

239604722 244429197
78993837 108804105

output:

-1

result:

ok correct!

Test #27:

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

input:

416861903 381749084
375027630 373683256

output:

-1

result:

ok correct!

Test #28:

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

input:

594119084 519068971
429116021 298715088

output:

-1

result:

ok correct!

Test #29:

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

input:

536870912 536870912
233225286 372408647

output:

29
0 0 0 536870912
0 268435456 536870912 536870912
0 268435456 268435456 402653184
134217728 335544320 268435456 402653184
201326592 369098752 268435456 402653184
201326592 369098752 234881024 385875968
218103808 369098752 234881024 377487360
226492416 369098752 234881024 373293056
230686720 3711959...

result:

wrong answer (218103808,369098752) is not in S