#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_N = 1e5 + 5;
void solve() {
int n; cin >> n;
int x[n],y[n];
char d[n];
for(int i=0; i<n; i++) {
cin >> x[i] >> y[i] >> d[i];
}
ll sudar[n+1][n+1];
for(int i=0; i<n; i++) {
for(int j=0; j<n; j++) {
if(i == j) {
sudar[i][j] = 1e18;
continue;
}
if(d[i] == 'S') {
if(d[j] == 'N') {
if(x[i] == x[j] and y[i] < y[j]) {
sudar[i][j] = (y[j]-y[i]) / 2;
} else {
sudar[i][j] = 1e18;
}
} else if(d[j] == 'E') {
if(x[i] + y[i] == x[j] + y[j] and y[i] < y[j]) {
sudar[i][j] = y[j] - y[i];
} else {
sudar[i][j] = 1e18;
}
} else if(d[j] == 'W') {
if(x[i] - y[i] == x[j] - y[j] and y[i] < y[j]) {
sudar[i][j] = y[j] - y[i];
} else {
sudar[i][j] = 1e18;
}
} else sudar[i][j] = 1e18;
}
else if(d[i] == 'N') {
if(d[j] == 'E') {
if(x[i] - y[i] == x[j] - y[j] and y[i] > y[j]) {
sudar[i][j] = y[i] - y[j];
} else {
sudar[i][j] = 1e18;
}
} else if(d[i] == 'W') {
if(x[i] + y[i] == x[j] + y[j] and y[i] > y[j]) {
sudar[i][j] = y[i] - y[j];
} else {
sudar[i][j] = 1e18;
}
} else {
sudar[i][j] = 1e18;
}
}
else if(d[i] == 'E') {
if(d[j] == 'W') {
if(y[i] == y[j] and x[i] < x[j]) {
sudar[i][j] = (x[j]-x[i]) / 2;
} else {
sudar[i][j] = 1e18;
}
} else {
sudar[i][j] = 1e18;
}
} else {
sudar[i][j] = 1e18;
}
}
}
set<pair<ll,pair<int,int>>>s;
for(int i=0; i<n; i++) {
for(int j=0; j<n; j++) {
if(sudar[i][j] != 1e18) {
s.insert({sudar[i][j], {i,j}});
}
}
}
vector<int>blown(n+1,0);
for(auto it = s.begin(); it != s.end(); it++) {
auto x = *it;
//cout << x.first << " " << x.second.first << " " << x.second.second << endl;
if(blown[x.second.first] > 0 and blown[x.second.first] != x.first or blown[x.second.second] > 0 and blown[x.second.second] != x.first) continue;
blown[x.second.first] = x.first;
blown[x.second.second] = x.first;
}
for(int i=0; i<n; i++) {
if(!blown[i]) cout << i+1 << endl;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int tc=1;
while(tc--)
solve();
}
# | 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... |