#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
#define fi first
#define se second
#define pb push_back
const int MOD = 1e9 + 7;
const int MAX = 2e5 + 5;
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
vector <pair<pii, char>> v;v.pb({{0, 0}, {'c'}});
int n; cin >> n;
for(int i = 0 ; i < n ; i++){
int x, y; cin >> x >> y;
char c; cin >> c;
v.pb({{x, y}, c});
}
bool dead[n + 5];memset(dead, 0, sizeof(dead));
int early[n + 5];memset(early, 0, sizeof(early));
vector <pair<int, pii>> ve;
for(int i = 1 ; i <= n ; i++){
for(int j = i + 1 ; j <= n ; j++){
if(i == j)continue;
if(v[i].se == v[j].se)continue;
int dx = abs(v[i].fi.fi - v[j].fi.fi);
int dy = abs(v[i].fi.se - v[j].fi.se);
if(v[i].se == 'N' && v[j].se == 'S'){
if(dx == 0 && v[i].fi.se > v[j].fi.se)ve.pb({dy / 2, {i, j}});
continue;
}
if(v[i].se == 'S' && v[j].se == 'N'){
if(dx == 0 && v[i].fi.se < v[j].fi.se)ve.pb({dy / 2, {i, j}});
continue;
}
if(v[i].se == 'W' && v[j].se == 'E' ){
if(dy == 0 && v[i].fi.fi > v[j].fi.fi)ve.pb({dx / 2, {i, j}});
continue;
}
if(v[i].se == 'E' && v[j].se == 'W'){
if(dy == 0 && v[i].fi.fi < v[j].fi.fi)ve.pb({dx / 2, {i, j}});
continue;
}
if(dx != dy)continue;
if(v[i].fi.fi < v[j].fi.fi){
if(v[i].fi.se > v[j].fi.se){
// T dan S atau U dan B
if(v[i].se == 'E' && v[j].se == 'S')ve.pb({dx, {i, j}});
if(v[i].se == 'N' && v[j].se == 'W')ve.pb({dx, {i, j}});
}
else{
// T dan U atau S dan B
if(v[i].se == 'E' && v[j].se == 'N')ve.pb({dx, {i, j}});
if(v[i].se == 'S' && v[j].se == 'W')ve.pb({dx, {i, j}});
}
}
else{
// >
if(v[i].fi.se > v[j].fi.se){
// U dan T atau B dan S
if(v[i].se == 'N' && v[j].se == 'E')ve.pb({dx, {i, j}});
if(v[i].se == 'W' && v[j].se == 'S')ve.pb({dx, {i, j}});
}
else{
// S dan T atau B dan U
if(v[i].se == 'S' && v[j].se == 'E')ve.pb({dx, {i, j}});
if(v[i].se == 'W' && v[j].se == 'N')ve.pb({dx, {i, j}});
}
}
}
}
sort(ve.begin(), ve.end());
for(int i = 0 ; i < (int)ve.size() ; i++){
int t = ve[i].fi;
int x = ve[i].se.fi;
int y = ve[i].se.se;
if(dead[x] && dead[y])continue;
else if(!dead[x] && !dead[y]){
early[x] = early[y] = t;
dead[x] = dead[y] = 1;
}
else{
if(dead[x]){
if(t == early[x]){
dead[y] = 1;
early[y] = t;
}
}
else{
if(t == early[y]){
dead[x] = 1;
early[x] = t;
}
}
}
}
for(int i = 0 ; i < n ; i++){
if(!dead[i])cout << i + 1 << '\n';
}
return 0;
}
| # | 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... |