Submission #1068787

#TimeUsernameProblemLanguageResultExecution timeMemory
1068787BigBadBullyNaval battle (CEOI24_battle)C++17
6 / 100
38 ms4956 KiB
// Online C++ compiler to run C++ program online #include <bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second struct ship{ int x,y; char dir; /* Northern — decreases the y coordinate by 1 Southern — increases the y coordinate by 1 Eastern — increases the x coordinate by 1 Western — decreases the x coordinate by 1 */ }; int calc(ship a, ship b) { if (a.dir == b.dir) return 0; if (a.x == b.x) { if (a.y < b.y) swap(a,b); if (a.dir == 'N' && b.dir == 'S') return (a.y-b.y)/2; return 0; } if (a.y == b.y) { if (a.x < b.x) swap(a,b); if (a.dir == 'W' && b.dir == 'E') return (a.x-b.x)/2; return 0; } if(a.dir == 'N') { if (b.dir == 'E') { if (b.y-a.y == b.x-a.x) return abs(a.x-b.x); } else if (b.dir == 'W') { if (a.x+a.y == b.y+b.x) return abs(a.x-b.x); } } else if (a.dir == 'S') { if (b.dir == 'E') { if (a.x+a.y == b.y+b.x) return abs(a.x-b.x); } else if (b.dir == 'W') { if (b.y-a.y == b.x-a.x) return abs(a.x-b.x); } } else if (a.dir == 'W') { if (b.dir == 'N') { if (a.x+a.y == b.y+b.x) return abs(a.x-b.x); } else if (b.dir == 'S') { if (b.y-a.y == b.x-a.x) return abs(a.x-b.x); } } else if (a.dir == 'E') { if (b.dir == 'N') { if (b.y-a.y == b.x-a.x) return abs(a.x-b.x); } else if (b.dir == 'S') { if (a.x+a.y == b.y+b.x) return abs(a.x-b.x); } } return 0; } signed main() { ios::sync_with_stdio(0); int n; cin >> n; vector<ship> v(n); for (int i = 0; i < n; i++) { cin >> v[i].x >> v[i].y >> v[i].dir; } if (n>2) { cout << "n\n"; return 0; } ship c = v[0]; ship d = v[1]; if (!calc(c,d)) { cout << "1\n2\n"; } return 0; }
#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...