Submission #724724

#TimeUsernameProblemLanguageResultExecution timeMemory
724724lukadupliPick (COI18_pick)C++14
10 / 100
1 ms304 KiB
#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)){ if(a == 0){ if(c == 0){ sol.push_back({0, 0}); sol.push_back({1, -1}); sol.push_back({1, 0}); sol.push_back({0, 1}); b -= 2; d -= 2; extend_b(2); extend_c(5); } else{ sol.push_back({0, 0}); sol.push_back({1, 1}); sol.push_back({1, 2}); sol.push_back({0, 1}); b -= 2; c -= 2; extend_b(2); extend_c(1); extend_d(7); } } else{ if(b == 0){ if(c == 0){ sol.push_back({0, 0}); sol.push_back({1, 0}); sol.push_back({0, 1}); sol.push_back({-1, 1}); a -= 2; d -= 2; extend_a(1); extend_d(4); } else{ sol.push_back({0, 0}); sol.push_back({1, 0}); sol.push_back({2, 1}); sol.push_back({1, 1}); a -= 2; c -= 2; extend_a(1); extend_c(4); extend_d(5); } } else{ 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 (stderr)

pick.cpp: In function 'int main()':
pick.cpp:189: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]
  189 |     for(int i = 0; i < sol.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...