#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;
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];memset(dead, 0, sizeof(dead));
int early[n + 5];memset(early, 0, sizeof(early));
vector <pair<int, pii>> ve;
for(int i = 0 ; i < n ; i++){
for(int j = 0 ; 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 == 'U' && 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 == 'U'){
if(dx == 0 && v[i].fi.se < v[j].fi.se)ve.pb({dy / 2, {i, j}});
continue;
}
if(v[i].se == 'B' && v[j].se == 'T' ){
if(dy == 0 && v[i].fi.fi > v[j].fi.fi)ve.pb({dx / 2, {i, j}});
continue;
}
if(v[i].se == 'T' && v[j].se == 'B'){
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 == 'T' && v[j].se == 'S')ve.pb({dx, {i, j}});
if(v[i].se == 'U' && v[j].se == 'B')ve.pb({dx, {i, j}});
}
else{
// T dan U atau S dan B
if(v[i].se == 'T' && v[j].se == 'U')ve.pb({dx, {i, j}});
if(v[i].se == 'S' && v[j].se == 'B')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 == 'U' && v[j].se == 'T')ve.pb({dx, {i, j}});
if(v[i].se == 'B' && 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 == 'T')ve.pb({dx, {i, j}});
if(v[i].se == 'B' && v[j].se == 'U')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;
}
Compilation message (stderr)
In file included from /usr/include/string.h:548,
from /usr/include/c++/13/cstring:42,
from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:121,
from Main.cpp:1:
In function 'void* memset(void*, int, size_t)',
inlined from 'int main()' at Main.cpp:23:21:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:59:33: warning: 'void* __builtin___memset_chk(void*, int, long unsigned int, long unsigned int)' specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
59 | return __builtin___memset_chk (__dest, __ch, __len,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
60 | __glibc_objsize0 (__dest));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~| # | 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... |