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 <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
class ship{
public:
ll x;
ll y;
char d;
ship(ll a, ll b, char c)
{
x=a;
y=b;
d=c;
}
ship()
{
cin >> x >> y >> d;
}
pll move(ll k)
{
if (d=='N')
return {x, y-k};
if (d=='S')
return {x, y+k};
if (d=='W')
return {x-k, y};
if (d=='E')
return {x+k, y};
return {x, y};
}
};
ll crash(ship ph, ship ch)
{
ll moves = abs(ph.x - ch.x) + abs(ph.y - ch.y);
moves = moves/2ll;
if (ph.move(moves) == ch.move(moves))
return moves;
return 0;
}
int main()
{
std::ios::sync_with_stdio(false);
int N;
cin >> N;
ship ss = ship();
ship po = ship();
if (crash(ss, po) == 0ll)
{
cout << "1\n2\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |