This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <algorithm>
#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
long long x1, y1, x2, y2, s;
cin >> x1 >> y1 >> x2 >> y2 >> s;
long long dx = abs(x2-x1), dy = abs(y2-y1), d = dx+dy;
if (s<d) { cout << "impossible" << endl; return 0; }
if (s==d) { cout << "0" << endl; return 0; }
if ((s-d)%2) { cout << "impossible" << endl; return 0; }
if (d==1) { cout << "impossible" << endl; return 0; }
if (dx==1 && dy==1) {
if (s==4) { cout << "impossible" << endl; return 0; }
int z=(s-4)/2;
cout << (2*z) << endl;
for (int i=1; i<=z; ++i) cout << x1 << " " << (y1+i*(y2-y1)) << endl;
for (int i=1; i<=z; ++i) cout << (x1+i*(x2-x1)) << " " << y1 << endl;
return 0;
}
if (abs(x2-x1) > 1) {
long long z = (s-d-2)/2;
long long x = (x1+x2)/2, miny = min(y1,y2)-z, maxy = max(y1,y2)+z;
cout << (maxy-miny+1) << endl;
for (long long y=miny; y<=maxy; ++y) cout << x << " " << y << endl;
} else {
long long z = (s-d-2)/2;
long long y = (y1+y2)/2, minx = min(x1,x2)-z, maxx = max(x1,x2)+z;
cout << (maxx-minx+1) << endl;
for (long long x=minx; x<=maxx; ++x) cout << x << " " << y << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |