이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |