이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<tuple<int, int, char, int>> ships(n);
int ii = 0;
for (auto& [x, y, c, i] : ships)
cin >> x >> y >> c, i = ii++;
sort(ships.begin(), ships.end(),
[&](tuple<int, int, char, int> a, tuple<int, int, char, int> b) {
auto [x1, y1, c1, i1] = a;
auto [x2, y2, c2, i2] = b;
return x1+y1 < x2+y2 || x1 < x2;
});
int prev = 0;
stack<int> st;
vector<bool> sunk(n);
for (auto& [x, y, c, i] : ships) {
if (x+y != prev)
st = stack<int>{};
prev = x+y;
if (c == 'E')
st.push(i);
else if (!st.empty())
sunk[i] = true, sunk[st.top()] = true, st.pop();
}
for (int i = 0; i < n; i++)
if (!sunk[i])
cout << i+1 << endl;
}
# | 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... |