Submission #1071532

#TimeUsernameProblemLanguageResultExecution timeMemory
1071532jer033Naval battle (CEOI24_battle)C++17
6 / 100
1 ms468 KiB
#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 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...