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 int long long
using namespace std;
struct S {
int x, y, d;
S(){}
};
map<char,int> trans = {{'N',0}, {'E',1}, {'S',2}, {'W',3}};
void solve() {
int n;
char temp;
cin >> n;
vector<S> a(n);
map<int,vector<int>> diag;
for(int i = 0; i < n; i++) {
cin >> a[i].x >> a[i].y >> temp;
a[i].d = trans[temp];
diag[a[i].x + a[i].y].push_back(i);
}
for(auto i : diag) {
sort(i.second.begin(), i.second.end(), [&](int x, int y){
return a[x].y > a[y].y;
});
stack<int> st;
for(int j = 0; j < i.second.size(); j++) {
if(a[i.second[j]].d == 1) st.push(i.second[j]);
else if(a[i.second[j]].d == 2) {
if(!st.size()) cout << i.second[j] + 1 << "\n";
else st.pop();
}
}
while(st.size()) {
cout << st.top() + 1 << "\n";
st.pop();
}
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
}
Compilation message (stderr)
Main.cpp: In function 'void solve()':
Main.cpp:28:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | for(int j = 0; j < i.second.size(); j++) {
| ~~^~~~~~~~~~~~~~~~~
# | 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... |