Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	static int X[200200];
	static int Y[200200];
	static string Type[200200];
	for(int i = 0; i < N; i++){
		cin >> X[i] >> Y[i] >> Type[i];
	}
	
	static vector<int> U[200200];
	static vector<int> R[200200];
	static set<int> D[200200];
	static set<int> L[200200];
	
	static set<int> U_[400400];
	static vector<int> R_[400400];
	static vector<int> D_[400400];
	static set<int> L_[400400];
	
	static vector<int> U__[400400];
	static vector<int> R__[400400];
	static set<int> D__[400400];
	static set<int> L__[400400];
	
	for(int i = 0; i < N; i++){
		if(Type[i] == "U"){
			U[X[i]].__emplace_back(Y[i]);
			U_[X[i]+Y[i]].insert(X[i]);
			U__[X[i]-Y[i]+200000].__emplace_back(X[i]);
		}else if(Type[i] == "R"){
			R[Y[i]].__emplace_back(X[i]);
			R_[X[i]+Y[i]].__emplace_back(X[i]);
			R__[X[i]-Y[i]+200000].__emplace_back(X[i]);
		}else if(Type[i] == "D"){
			D[X[i]].insert(Y[i]);
			D_[X[i]+Y[i]].__emplace_back(X[i]);
			D__[X[i]-Y[i]+200000].insert(X[i]);
		}else{
			L[Y[i]].insert(X[i]);
			L_[X[i]+Y[i]].insert(X[i]);
			L__[X[i]-Y[i]+200000].insert(X[i]);
		}
		
		
	}
	
	int SAFE = 10000000;
	int ans = SAFE;
	for(int i = 0; i <= 200000; i++){
		if(U[i].size() > 0 && D[i].size() > 0){
			for(int j = 0; j < U[i].size(); j++){
				auto near = lower_bound(D[i].begin(), D[i].end(), U[i][j]);
				if(near != D[i].end()){
					ans = min(ans, 5*(*near - U[i][j]));
				}
			}
		}
		
		if(R[i].size() > 0 && L[i].size() > 0){
			for(int j = 0; j < R[i].size(); j++){
				auto near = lower_bound(L[i].begin(), L[i].end(), R[i][j]);
				if(near != L[i].end()){
					ans = min(ans, 5*(*near - R[i][j]));
				}
			}
		}
	}
	
	// 斜め衝突
	for(int i = 0; i <= 400000; i++){
		if(R_[i].size() > 0 && U_[i].size() > 0){
			for(int j = 0; j < R_[i].size(); j++){
				auto near = lower_bound(U_[i].begin(), U_[i].end(), R_[i][j]);
				if(near != U_[i].end()){
					ans = min(ans, 10*(*near - R_[i][j]));
				}
			}
		}
		if(D_[i].size() > 0 && L_[i].size() > 0){
			for(int j = 0; j < D_[i].size(); j++){
				auto near = lower_bound(L_[i].begin(), L_[i].end(), D_[i][j]);
				if(near != L_[i].end()){
					ans = min(ans, 10*(*near - D_[i][j]));
				}
			}
		}
	}
	
	// 斜め衝突２
	for(int i = 0; i <= 400000; i++){
		if(U__[i].size() > 0 && L__[i].size() > 0){
			for(int j = 0; j < U__[i].size(); j++){
				auto near = lower_bound(L__[i].begin(), L__[i].end(), U__[i][j]);
				if(near != L__[i].end()){
					ans = min(ans, 10*(*near - U__[i][j]));
				}
			}
		}
		if(R__[i].size() > 0 && D__[i].size() > 0){
			for(int j = 0; j < R__[i].size(); j++){
				auto near = lower_bound(D__[i].begin(), D__[i].end(), R__[i][j]);
				if(near != D__[i].end()){
					ans = min(ans, 10*(*near - R__[i][j]));
				}
			}
		}
	}
	
	if(ans == SAFE){
		cout << "SAFE" << endl;
	}else{
		cout << ans << endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:33: error: 'class std::vector<int>' has no member named '__emplace_back'; did you mean 'emplace_back'?
   49 |                         U[X[i]].__emplace_back(Y[i]);
      |                                 ^~~~~~~~~~~~~~
      |                                 emplace_back
a.cc:51:47: error: 'class std::vector<int>' has no member named '__emplace_back'; did you mean 'emplace_back'?
   51 |                         U__[X[i]-Y[i]+200000].__emplace_back(X[i]);
      |                                               ^~~~~~~~~~~~~~
      |                                               emplace_back
a.cc:53:33: error: 'class std::vector<int>' has no member named '__emplace_back'; did you mean 'emplace_back'?
   53 |                         R[Y[i]].__emplace_back(X[i]);
      |                                 ^~~~~~~~~~~~~~
      |                                 emplace_back
a.cc:54:39: error: 'class std::vector<int>' has no member named '__emplace_back'; did you mean 'emplace_back'?
   54 |                         R_[X[i]+Y[i]].__emplace_back(X[i]);
      |                                       ^~~~~~~~~~~~~~
      |                                       emplace_back
a.cc:55:47: error: 'class std::vector<int>' has no member named '__emplace_back'; did you mean 'emplace_back'?
   55 |                         R__[X[i]-Y[i]+200000].__emplace_back(X[i]);
      |                                               ^~~~~~~~~~~~~~
      |                                               emplace_back
a.cc:58:39: error: 'class std::vector<int>' has no member named '__emplace_back'; did you mean 'emplace_back'?
   58 |                         D_[X[i]+Y[i]].__emplace_back(X[i]);
      |                                       ^~~~~~~~~~~~~~
      |                                       emplace_back