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]].resize(1024);
			U_[X[i]+Y[i]].resize(1024);
			U__[X[i]-Y[i]+200000].resize(1024);
			
			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]);
			
			R[Y[i]].resize(1024);
			R_[X[i]+Y[i]].resize(1024);
			R__[X[i]-Y[i]+200000].resize(1024);
		}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]);
			
			D[X[i]].resize(1024);
			D_[X[i]+Y[i]].resize(1024);
			D__[X[i]-Y[i]+200000].resize(1024);
		}else{
			L[Y[i]].insert(X[i]);
			L_[X[i]+Y[i]].insert(X[i]);
			L__[X[i]-Y[i]+200000].insert(X[i]);
			
			L[Y[i]].resize(1024);
			L_[X[i]+Y[i]].resize(1024);
			L__[X[i]-Y[i]+200000].resize(1024);
		}
		
		
	}
	
	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:50:39: error: 'class std::set<int>' has no member named 'resize'; did you mean 'size'?
   50 |                         U_[X[i]+Y[i]].resize(1024);
      |                                       ^~~~~~
      |                                       size
a.cc:69:33: error: 'class std::set<int>' has no member named 'resize'; did you mean 'size'?
   69 |                         D[X[i]].resize(1024);
      |                                 ^~~~~~
      |                                 size
a.cc:71:47: error: 'class std::set<int>' has no member named 'resize'; did you mean 'size'?
   71 |                         D__[X[i]-Y[i]+200000].resize(1024);
      |                                               ^~~~~~
      |                                               size
a.cc:77:33: error: 'class std::set<int>' has no member named 'resize'; did you mean 'size'?
   77 |                         L[Y[i]].resize(1024);
      |                                 ^~~~~~
      |                                 size
a.cc:78:39: error: 'class std::set<int>' has no member named 'resize'; did you mean 'size'?
   78 |                         L_[X[i]+Y[i]].resize(1024);
      |                                       ^~~~~~
      |                                       size
a.cc:79:47: error: 'class std::set<int>' has no member named 'resize'; did you mean 'size'?
   79 |                         L__[X[i]-Y[i]+200000].resize(1024);
      |                                               ^~~~~~
      |                                               size