Submission #850951

# Submission time Handle Problem Language Result Execution time Memory
850951 2023-09-18T02:41:56 Z Cyanmond Pick (COI18_pick) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>

using namespace std;

#define rep(i, l, r) for (int i = (l); i < (r); ++i)
#define per(i, l, r) for (int i = (r - 1); i >= l; --i)
#define ALL(x) (x).begin(), (x).end()

using i64 = long long;

void main_() {
    i64 A, B, C, D;
    cin >> A >> B >> C >> D;

    vector<pair<int, int>> ans;
    rep(a1, 0, A + 1) {
        i64 a2 = A - a1;
        rep(b1, 0, B + 1) {
            i64 b2 = B - b1;
            rep(c1, 0, C + 1) {
                i64 c2 = C - c1;
                
                i64 xsum = a1 - a2 + c1 - c2;
                i64 ysum = b1 - b2 + c1 - c2;
                if (xsum + ysum != 0) continue;
                rep(d1, 0, D + 1) {
                    i64 d2 = D - d1;
                    xsum += d1 - d2;
                    ysum += d2 - d1;
                    if (xsum != 0 or ysum != 0) continue;

                    // loop : O(n^2)
                    int x = 0, y = 0;
                    vector<pair<int, int>> res;

                    auto moveD = [&](int ax, int ay) {
                        res.push_back({x, y});
                        x += ax, y += ay;
                    };

                    rep(i, 0, a1) moveD(1, 0);
                    rep(i, 0, d1) moveD(1, -1);
                    rep(i, 0, b2) moveD(0, -1);
                    rep(i, 0, c2) moveD(-1, -1);
                    rep(i, 0, a2) moveD(1, -1);
                    rep(i, 0, d2) moveD(-1, 1);
                    rep(i, 0, b1) moveD(0, 1);
                    rep(i, 0, c1) moveD(1, 1);
                    ans = move(res);
                }
            }
        }
    }

    for (const auto &[x, y] : ans) {
        cout << x << ' ' << y << endl;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    main_();
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB not a valid stick
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB not a valid stick
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB not a valid stick
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB not a valid stick
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB not a valid stick
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB not a valid stick
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB not a valid stick
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB not a valid stick
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB not a valid stick
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB not a valid stick
2 Halted 0 ms 0 KB -