답안 #724720

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
724720 2023-04-15T18:45:03 Z lukadupli Pick (COI18_pick) C++14
10 / 100
1 ms 212 KB
#include <bits/stdc++.h>

#define f first
#define s second

using namespace std;

typedef pair<int, int> pii;

int a, b, c, d;
vector<pii> sol;

void extend_a(int pos){
    int n = (pos + 1) % sol.size();
    pii n1 = {sol[pos].f + a / 2, sol[pos].s};
    pii n2 = {sol[n].f + a / 2, sol[n].s};
    sol.insert(sol.begin() + pos + 1, {n1, n2});
}
void extend_b(int pos){
    int n = (pos + 1) % sol.size();
    pii n1 = {sol[pos].f, sol[pos].s + b / 2};
    pii n2 = {sol[n].f, sol[n].s + b / 2};
    sol.insert(sol.begin() + pos + 1, {n1, n2});
}
void extend_c(int pos){
    int n = (pos + 1) % sol.size();
    pii n1 = {sol[pos].f + c / 2, sol[pos].s + c / 2};
    pii n2 = {sol[n].f + c / 2, sol[n].s + c / 2};
    sol.insert(sol.begin() + pos + 1, {n1, n2});
}
void extend_d(int pos, int dir = 1){
    int n = (pos + 1) % sol.size();
    pii n1 = {sol[pos].f - dir * d / 2, sol[pos].s + dir * d / 2};
    pii n2 = {sol[n].f - dir * d / 2, sol[n].s + dir * d / 2};
    sol.insert(sol.begin() + pos + 1, {n1, n2});
}

int main()
{
    cin >> a >> b >> c >> d;

    if(a == 0 && b == 0){
        sol.push_back({0, 0});
        sol.push_back({1, 1});
        sol.push_back({0, 2});
        sol.push_back({-1, 1});

        c -= 2;
        d -= 2;

        extend_c(1);
        extend_d(4);
    }
    else{
        if(!(a % 2) && !(b % 2) && !(c % 2) && !(d % 2)){
            sol.push_back({0, 0});
            sol.push_back({0, 1});
            sol.push_back({-1, 1});
            sol.push_back({-1, 0});

            a -= 2;
            b -= 2;

            extend_a(0);
            extend_b(3);
            extend_c(1);
            extend_d(6);
        }
        else if(!(a % 2) && !(b % 2) && c % 2 && d % 2){
            if(a == 0){
                sol.push_back({0, 0});
                sol.push_back({0, 1});
                sol.push_back({0, 2});
                sol.push_back({-1, 1});

                b -= 2;
                c--;
                d--;

                extend_b(2);
                extend_c(1);
                extend_d(0, -1);
            }
            else{
                sol.push_back({0, 0});
                sol.push_back({1, 1});
                sol.push_back({0, 1});
                sol.push_back({-1, 1});

                a -= 2;
                c--;
                d--;

                extend_a(0);
                extend_b(3);
                extend_c(4);
                extend_d(8);
            }
        }
        else if(a % 2 && b % 2 && !(c % 2) && d % 2){
            sol.push_back({0, 0});
            sol.push_back({0, 1});
            sol.push_back({-1, 1});

            a--;
            b--;
            d--;

            extend_a(0);
            extend_b(3);
            extend_c(1);
            extend_d(6);
        }
        else if(a % 2 && b % 2 && c % 2 && !(d % 2)){
            sol.push_back({0, 0});
            sol.push_back({1, 0});
            sol.push_back({1, 1});

            a--;
            b--;
            c--;

            extend_a(1);
            extend_b(4);
            extend_c(2);
            extend_d(0);
        }
    }

    sol.push_back(sol.front());
    for(int i = 0; i < sol.size(); i++){
        int x = sol[i].f, y = sol[i].s;

        int dx = sol[i + 1].f - sol[i].f;
        if(dx) dx /= abs(dx);
        int dy = sol[i + 1].s - sol[i].s;
        if(dy) dy /= abs(dy);

        while(x != sol[i + 1].f || y != sol[i + 1].s){
            cout << x << ' ' << y << '\n';
            x += dx; y += dy;
        }
    }



	return 0;
}

Compilation message

pick.cpp: In function 'int main()':
pick.cpp:131:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  131 |     for(int i = 0; i < sol.size(); i++){
      |                    ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB number of sticks is not consistent with the given input
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB number of sticks is not consistent with the given input
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB number of sticks is not consistent with the given input
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB number of sticks is not consistent with the given input
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB number of sticks is not consistent with the given input
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB number of sticks is not consistent with the given input
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB number of sticks is not consistent with the given input
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB number of sticks is not consistent with the given input
10 Halted 0 ms 0 KB -