# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1068387 | faruk | Naval battle (CEOI24_battle) | C++17 | 3081 ms | 23624 KiB |
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>
#define all(a) a.begin(), a.end()
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
struct ship {
char c;
int x, y, idx;
ship() {}
ship(char c, int x, int y) : x(x), y(y), c(c) {}
bool operator<(const ship& b) const {
return pii(x, y) < pii(b.x, b.y);
}
bool operator==(const ship&b) const {
return idx == b.idx;
}
};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<ship> guys(n);
for (int i = 0; i < n; i++)
{
cin >> guys[i].x >> guys[i].y >> guys[i].c;
guys[i].idx = i + 1;
}
for (int i = 0; i <= 110; i++) {
map<pii, int> coords;
for (ship &s : guys) {
if (s.c == 'N')
s.y--;
if (s.c == 'S')
s.y++;
if (s.c == 'E')
s.x++;
if (s.y == 'W')
s.x--;
coords[pii(s.x, s.y)]++;
}
vector<ship> new_guys;
for (ship &s : guys)
if (coords[pii(s.x, s.y)] == 1)
new_guys.push_back(s);
guys = new_guys;
}
for (ship s : guys)
cout << s.idx << "\n";
}
Compilation message (stderr)
# | 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... |