Submission #144592

#TimeUsernameProblemLanguageResultExecution timeMemory
144592SamAndPick (COI18_pick)C++17
10 / 100
3 ms376 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...