Submission #144592

# Submission time Handle Problem Language Result Execution time Memory
144592 2019-08-17T09:09:43 Z SamAnd Pick (COI18_pick) C++17
10 / 100
3 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
const int xx[8] = {1, 0, 1, 1, -1, 0, -1, -1};
const int yy[8] = {0, 1, 1, -1, 0, -1, -1, 1};

int a, b, c, d;

void solv1()
{
    int x = 0, y = 0;
    for (int i = 0; i < a / 2; ++i)
    {
        cout << x << ' ' << y << endl;
        x += xx[0];
        y += yy[0];
    }
    for (int i = 0; i < b / 2; ++i)
    {
        cout << x << ' ' << y << endl;
        x += xx[1];
        y += yy[1];
    }
    for (int i = 0; i < a / 2; ++i)
    {
        cout << x << ' ' << y << endl;
        x += xx[4];
        y += yy[4];
    }
    for (int i = 0; i < b / 2; ++i)
    {
        cout << x << ' ' << y << endl;
        x += xx[5];
        y += yy[5];
    }
}

void solv2()
{
    int x = 0, y = 0;
    for (int i = 0; i < c / 2; ++i)
    {
        cout << x << ' ' << y << endl;
        x += xx[2];
        y += yy[2];
    }
    for (int i = 0; i < d / 2; ++i)
    {
        cout << x << ' ' << y << endl;
        x += xx[3];
        y += yy[3];
    }
    for (int i = 0; i < c / 2; ++i)
    {
        cout << x << ' ' << y << endl;
        x += xx[6];
        y += yy[6];
    }
    for (int i = 0; i < d / 2; ++i)
    {
        cout << x << ' ' << y << endl;
        x += xx[7];
        y += yy[7];
    }
}

vector<pair<int, int> > v;
map<int, map<int, bool> > cc;
void rec(int x, int y)
{
    if (a == 0 && b == 0 && c == 0 && d == 0 && x == 0 && y == 0)
    {
        for (int i = 0; i < v.size(); ++i)
            cout << v[i].first << ' ' << v[i].second << endl;
        exit(0);
    }
    if (cc[x][y])
        return;
    cc[x][y] = true;
    v.push_back(m_p(x, y));
    if (a)
    {
        --a;
        rec(x + xx[0], y + yy[0]);
        rec(x + xx[4], y + yy[4]);
        ++a;
    }
    if (b)
    {
        --b;
        rec(x + xx[1], y + yy[1]);
        rec(x + xx[5], y + yy[5]);
        ++b;
    }
    if (c)
    {
        --c;
        rec(x + xx[2], y + yy[2]);
        rec(x + xx[6], y + yy[6]);
        ++c;
    }
    if (d)
    {
        --d;
        rec(x + xx[3], y + yy[3]);
        rec(x + xx[7], y + yy[7]);
        ++d;
    }
    v.pop_back();
    cc[x][y] = false;
}

int main()
{
    cin >> a >> b >> c >> d;
    if (c == 0 && d == 0)
    {
        solv1();
    }
    else if (a == 0 && b == 0)
    {
        solv2();
    }
    else
        rec(0, 0);
    return 0;
}

Compilation message

pick.cpp: In function 'void rec(int, int)':
pick.cpp:73:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < v.size(); ++i)
                         ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB not a simple polygon
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB not a simple polygon
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB not a simple polygon
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB not a simple polygon
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB not a simple polygon
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Incorrect 2 ms 376 KB not a simple polygon
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Incorrect 2 ms 376 KB not a simple polygon
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Incorrect 2 ms 376 KB not a simple polygon
11 Halted 0 ms 0 KB -