Submission details
Task:Hypyt
Sender:jhuun
Submission time:2025-10-18 19:29:02 +0300
Language:C++ (C++20)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED30
#2ACCEPTED70
Test results
testverdicttimegroup
#1ACCEPTED0.00 s1, 2details
#2ACCEPTED0.00 s1, 2details
#3ACCEPTED0.02 s2details
#4ACCEPTED0.04 s2details
#5ACCEPTED0.06 s2details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:54:25: warning: loop variable '<structured bindings>' creates a copy from type 'const std::pair<int, int>' [-Wrange-loop-construct]
   54 |         for (const auto [dy, dx] : solve(pi(n, m))) {
      |                         ^~~~~~~~
input/code.cpp:54:25: note: use reference type to prevent copying
   54 |         for (const auto [dy, dx] : solve(pi(n, m))) {
      |                         ^~~~~~~~
      |                         &

Code

#include <bits/stdc++.h>

using pi = std::pair<int, int>;

std::map<pi, std::vector<pi>> M = [](){
    std::map<pi, std::vector<pi>> M_;
    M_[pi(1, 1)] = {};
    M_[pi(1, 2)] = {pi(0, 1)};
    M_[pi(2, 1)] = {pi(1, 0)};
    M_[pi(2, 2)] = {pi(1, 0), pi(0, 1), pi(-1, 0)};
    return M_;
}();

pi r2(pi yx) {
    const auto [y, x] = yx;
    return y < x ? pi(y, x - 2) : pi(y - 2, x);
}

std::vector<pi> L(pi yx) {
    std::vector<pi> LM;
    const auto [y, x] = yx;
    if (y < x) {
        for (int i = y - 1, s = 1; i >= -y + 1; --i, s *= -1) {
            LM.emplace_back(s * i, s * (x - 1));
        }
        LM.emplace_back(0, -x + 2);
    } else {
        for (int i = x - 1, s = 1; i >= -x + 1; --i, s *= -1) {
            LM.emplace_back(s * (y - 1), s * i);
        }
        LM.emplace_back(-y + 2, 0);
    }
    return LM;
}

std::vector<pi> solve(pi yx) {
    if (M.count(yx)) {
        return M[yx];
    }
    std::vector<pi> m = L(yx);
    const auto& m2 = solve(r2(yx));
    for (const auto& yx2 : m2) {
        m.push_back(yx2);
    }
    return M[yx] = m;
}

int main() {
    int t;
    std::cin >> t;
    for (int i = 0; i < t; ++i) {
        int n, m;
        std::cin >> n >> m;
        for (const auto [dy, dx] : solve(pi(n, m))) {
            std::cout << dy << ' ' << dx << '\n';
        }
    }
}

Test details

Test 1

Group: 1, 2

Verdict: ACCEPTED

input
25
1 1
1 2
1 3
1 4
...

correct output
0 1
0 2
0 -1
0 3
0 -2
...

user output
0 1
0 2
0 -1
0 3
0 -2
...

Test 2

Group: 1, 2

Verdict: ACCEPTED

input
100
5 5
5 5
5 5
5 5
...

correct output
4 4
-4 -3
4 2
-4 -1
4 0
...

user output
4 4
-4 -3
4 2
-4 -1
4 0
...

Test 3

Group: 2

Verdict: ACCEPTED

input
100
1 25
20 40
5 34
50 34
...

correct output
0 24
0 -23
0 22
0 -21
0 20
...

user output
0 24
0 -23
0 22
0 -21
0 20
...

Test 4

Group: 2

Verdict: ACCEPTED

input
100
46 47
41 39
46 36
46 30
...

correct output
45 46
-45 -45
45 44
-45 -43
45 42
...

user output
45 46
-44 -46
43 46
-42 -46
41 46
...

Test 5

Group: 2

Verdict: ACCEPTED

input
100
50 50
50 50
50 50
50 50
...

correct output
49 49
-49 -48
49 47
-49 -46
49 45
...

user output
49 49
-49 -48
49 47
-49 -46
49 45
...