답안 #724704

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
724704 2023-04-15T18:02:06 Z lukadupli Pick (COI18_pick) C++14
10 / 100
1 ms 304 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 n = (pos + 1) % sol.size();
    pii n1 = {sol[pos].f - d / 2, sol[pos].s + d / 2};
    pii n2 = {sol[n].f - d / 2, sol[n].s + 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);
            }
            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_c(1);
                extend_d(4);
                extend_a(2);
                extend_d(7);
            }
        }
        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 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 304 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 1 ms 212 KB number of sticks is not consistent with the given input
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB number of sticks is not consistent with the given input
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB number of sticks is not consistent with the given input
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB number of sticks is not consistent with the given input
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 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 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 1 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 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 1 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 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB number of sticks is not consistent with the given input
10 Halted 0 ms 0 KB -