QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#60131#1900. Octopus GameMostafa_Moharram#WA 2ms3728kbC++171.1kb2022-11-03 00:16:302022-11-03 00:16:32

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-03 00:16:32]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3728kb
  • [2022-11-03 00:16:30]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

#define F first
#define S second

vector<pair<int, ll>> vp;

void gcd(ll a, ll b) {
    int v1 = 1;
    int v2 = 2;
    while (b) {
        ll c = a % b;
        if (a >= b)
            vp.emplace_back(v1, -a / b);
        a = b;
        b = c;
        swap(v1, v2);
    }
}

int main() {
    ios::sync_with_stdio(false); cout.tie(nullptr); cin.tie(nullptr);
    ll a, b;
    cin >> a >> b;
    if (a < 0 and b < 0) {
        if (b < a) {
            a -= b;
            vp.emplace_back(1, -1);
        } else {
            b -= a;
            vp.emplace_back(2, -1);
        }
    }
    if (a < 0 and b) {
        ll tmp = (abs(a) + b - 1) / b;
        a += tmp * b;
        vp.emplace_back(1, tmp);
    }
    if (b < 0 and a) {
        ll tmp = (abs(b) + a - 1) / a;
        b += tmp * a;
        vp.emplace_back(2, tmp);
    }
    gcd(a, b);
    cout << vp.size() << '\n';
    for (const auto &p : vp)
        cout << p.F << ' ' << p.S << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

-3 9

output:

3
1 1
2 -1
1 -2

result:

ok heap reached 0 count in less than 50 steps

Test #2:

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

input:

-27 57

output:

4
1 1
2 -1
1 -1
2 -9

result:

ok heap reached 0 count in less than 50 steps

Test #3:

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

input:

56 15

output:

5
1 -3
2 -1
1 -2
2 -1
1 -3

result:

ok heap reached 0 count in less than 50 steps

Test #4:

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

input:

6 -2

output:

3
2 1
1 -1
2 -2

result:

ok heap reached 0 count in less than 50 steps

Test #5:

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

input:

-84 57

output:

4
1 2
2 -1
1 -1
2 -9

result:

ok heap reached 0 count in less than 50 steps

Test #6:

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

input:

-648 -315

output:

4
2 -1
1 2
2 -18
1 -2

result:

ok heap reached 0 count in less than 50 steps

Test #7:

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

input:

4418 -527

output:

11
2 1
1 -1
2 -7
1 -2
2 -1
1 -1
2 -1
1 -1
2 -3
1 -1
2 -8

result:

ok heap reached 0 count in less than 50 steps

Test #8:

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

input:

55796 83094

output:

9
2 -1
1 -2
2 -22
1 -1
2 -2
1 -1
2 -36
1 -1
2 -3

result:

ok heap reached 0 count in less than 50 steps

Test #9:

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

input:

581706 382159

output:

15
1 -1
2 -1
1 -1
2 -10
1 -1
2 -3
1 -1
2 -1
1 -1
2 -1
1 -3
2 -6
1 -1
2 -3
1 -7

result:

ok heap reached 0 count in less than 50 steps

Test #10:

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

input:

-1570717 -5452307

output:

19
1 -1
2 2
1 -1
2 -1
1 -2
2 -8
1 -5
2 -2
1 -1
2 -9
1 -2
2 -2
1 -1
2 -1
1 -1
2 -3
1 -1
2 -1
1 -3

result:

ok heap reached 0 count in less than 50 steps

Test #11:

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

input:

35296299 62120456

output:

14
2 -1
1 -1
2 -3
1 -6
2 -54
1 -1
2 -1
1 -1
2 -10
1 -5
2 -2
1 -1
2 -9
1 -5

result:

ok heap reached 0 count in less than 50 steps

Test #12:

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

input:

133453354 276321715

output:

17
2 -2
1 -14
2 -5
1 -1
2 -2
1 -1
2 -2
1 -3
2 -2
1 -1
2 -1
1 -1
2 -18
1 -1
2 -4
1 -7
2 -7

result:

ok heap reached 0 count in less than 50 steps

Test #13:

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

input:

4087302427 739712346

output:

22
1 -5
2 -1
1 -1
2 -9
1 -3
2 -2
1 -2
2 -1
1 -1
2 -4
1 -1
2 -5
1 -2
2 -1
1 -1
2 -14
1 -1
2 -21
1 -1
2 -2
1 -1
2 -3

result:

ok heap reached 0 count in less than 50 steps

Test #14:

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

input:

30857859855 -36651946276

output:

18
2 2
1 -1
2 -4
1 -3
2 -14
1 -3
2 -8
1 -33
2 -7
1 -2
2 -1
1 -3
2 -1
1 -13
2 -1
1 -1
2 -2
1 -21

result:

ok heap reached 0 count in less than 50 steps

Test #15:

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

input:

290684430189 -337396975722

output:

24
2 2
1 -1
2 -5
1 -4
2 -2
1 -19
2 -1
1 -2
2 -1
1 -1
2 -1
1 -5
2 -1
1 -1
2 -1
1 -1
2 -10
1 -3
2 -3
1 -3
2 -2
1 -1
2 -1
1 -4

result:

ok heap reached 0 count in less than 50 steps

Test #16:

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

input:

4018564636210 2812471427308

output:

24
1 -1
2 -2
1 -3
2 -76
1 -2
2 -2
1 -1
2 -1
1 -49
2 -1
1 -1
2 -1
1 -1
2 -2
1 -1
2 -7
1 -1
2 -3
1 -3
2 -1
1 -3
2 -1
1 -116
2 -3

result:

ok heap reached 0 count in less than 50 steps

Test #17:

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

input:

46017810015419 -48982225298334

output:

29
2 2
1 -1
2 -14
1 -1
2 -1
1 -10
2 -5
1 -2
2 -7
1 -2
2 -3
1 -2
2 -3
1 -7
2 -2
1 -1
2 -7
1 -3
2 -1
1 -3
2 -7
1 -1
2 -1
1 -4
2 -1
1 -2
2 -1
1 -15
2 -2

result:

ok heap reached 0 count in less than 50 steps

Test #18:

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

input:

-791828028554116 -417054265497197

output:

28
2 -1
1 3
2 -1
1 -7
2 -1
1 -6
2 -2
1 -1
2 -5
1 -4
2 -3
1 -1
2 -9
1 -1
2 -105
1 -1
2 -26
1 -1
2 -7
1 -4
2 -1
1 -42
2 -3
1 -4
2 -1
1 -3
2 -2
1 -2

result:

ok heap reached 0 count in less than 50 steps

Test #19:

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

input:

9958409834380717 -5355316404922545

output:

36
2 1
1 -2
2 -6
1 -8
2 -2
1 -1
2 -1
1 -1
2 -2
1 -13
2 -1
1 -10
2 -1
1 -1
2 -15
1 -1
2 -9
1 -1
2 -9
1 -1
2 -3
1 -3
2 -1
1 -2
2 -1
1 -3
2 -1
1 -1
2 -12
1 -1
2 -31
1 -1
2 -4
1 -1
2 -1
1 -2

result:

ok heap reached 0 count in less than 50 steps

Test #20:

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

input:

73118300939404300 -89660288210986608

output:

34
2 2
1 -1
2 -3
1 -2
2 -2
1 -1
2 -1
1 -1
2 -2
1 -2
2 -18
1 -7
2 -1
1 -1
2 -1
1 -1
2 -4
1 -22
2 -1
1 -2
2 -1
1 -47
2 -6
1 -1
2 -60
1 -1
2 -4
1 -1
2 -2
1 -5
2 -2
1 -1
2 -3
1 -5

result:

ok heap reached 0 count in less than 50 steps

Test #21:

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

input:

-698819961200024568 438960282374739748

output:

37
1 2
2 -2
1 -2
2 -4
1 -1
2 -1
1 -2
2 -5
1 -2
2 -4
1 -1
2 -1
1 -3
2 -3
1 -2
2 -11
1 -2
2 -1
1 -3
2 -2
1 -4
2 -2
1 -24
2 -4
1 -1
2 -2
1 -2
2 -6
1 -1
2 -3
1 -1
2 -4
1 -1
2 -11
1 -5
2 -1
1 -7

result:

ok heap reached 0 count in less than 50 steps

Test #22:

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

input:

1 3

output:

1
2 -3

result:

ok heap reached 0 count in less than 50 steps

Test #23:

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

input:

-89 144

output:

10
1 1
2 -2
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -2

result:

ok heap reached 0 count in less than 50 steps

Test #24:

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

input:

10946 -17711

output:

19
2 2
1 -2
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -2

result:

ok heap reached 0 count in less than 50 steps

Test #25:

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

input:

2178309 1346269

output:

30
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -2

result:

ok heap reached 0 count in less than 50 steps

Test #26:

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

input:

-1346269 679891637638612258

output:

13
1 1
2 -1
1 -505019158605
2 -1
1 -16
2 -1
1 -16
2 -1
1 -16
2 -1
1 -16
2 -1
1 -12

result:

ok heap reached 0 count in less than 50 steps

Test #27:

score: -100
Wrong Answer
time: 2ms
memory: 3652kb

input:

365435296162 225851433717

output:

55
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -1
2 -1
1 -2

result:

wrong answer used more than 50 steps