# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
724724 |
2023-04-15T19:07:52 Z |
lukadupli |
Pick (COI18_pick) |
C++14 |
|
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 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
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 time |
Memory |
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 |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
0 ms |
304 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Incorrect |
1 ms |
212 KB |
not a simple polygon |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
0 ms |
304 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Incorrect |
1 ms |
212 KB |
not a simple polygon |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
0 ms |
304 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Incorrect |
1 ms |
212 KB |
not a simple polygon |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
0 ms |
304 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Incorrect |
1 ms |
212 KB |
not a simple polygon |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
0 ms |
304 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Incorrect |
1 ms |
212 KB |
not a simple polygon |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
1 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 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
304 KB |
Output is correct |
12 |
Correct |
1 ms |
300 KB |
Output is correct |
13 |
Correct |
0 ms |
304 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Incorrect |
1 ms |
212 KB |
not a simple polygon |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
1 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 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
304 KB |
Output is correct |
12 |
Correct |
1 ms |
300 KB |
Output is correct |
13 |
Correct |
0 ms |
304 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Incorrect |
1 ms |
212 KB |
not a simple polygon |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
1 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 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
304 KB |
Output is correct |
12 |
Correct |
1 ms |
300 KB |
Output is correct |
13 |
Correct |
0 ms |
304 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Incorrect |
1 ms |
212 KB |
not a simple polygon |
18 |
Halted |
0 ms |
0 KB |
- |