Language: C++

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
#define ld long double
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //cin,coutの高速化
    int n;
    cin>>n;
    vector<int> x(n),y(n);
    vector<char> u(n);
    map<int,vector<int>> plus;
    map<int,vector<int>> m1,m2,ex,wi;
    rep(i,n){
        cin>>x[i]>>y[i]>>u[i];
        plus[x[i]+y[i]].push_back(i);
        m1[x[i]-y[i]].push_back(i);
        ex[x[i]].push_back(i);
        wi[y[i]].push_back(i);
    }
    bool crush = false;
    int64_t time=100000000;
    for(int i=0;i<n;i++){
        if(u[i]=='U'){
            if(plus[x[i]+y[i]].size()>1){
                for(auto c:plus[x[i]+y[i]]){
                    if(u[c]=='R'){
                        if(x[i]-x[c]>0){
                            crush = true;
                            time = min(time,10*(x[i]-x[c]));
                        }
                    }
                }
            }
            if(ex[x[i]].size()>1){
                for(auto c:ex[x[i]]){
                    if(u[c]=='D'){
                        if(y[c]-y[i]>0){
                            crush = true;
                            time = min(time,5*(y[c]-y[i]));
                        }
                    }
                }
            }
            if(m1[x[i]-y[i]].size()>1){
                for(auto c:m1[x[i]-y[i]]){
                    if(u[c]=='L'){
                        if(x[c]-x[i]>0){
                            crush = true;
                            time = min(time,10*(x[c]-x[i]));
                        }
                    }
                }
            }
        }
        if(u[i]=='D'){
            if(m1[x[i]-y[i]].size()>1){
                for(auto c:m1[x[i]-y[i]]){
                    if(u[c]=='R'){
                        if(x[i]-x[c]>0){
                            crush = true;
                            time = min(time,10*(x[i]-x[c]));
                        }
                    }
                }
            }
            if(plus[x[i]+y[i]].size()>1){
                for(auto c:plus[x[i]+y[i]]){
                    if(u[c]=='L'){
                        if(x[c]-x[i]>0){
                            crush = true;
                            time=min(time,10*(x[c]-x[i]));
                        }
                    }
                }
            }
        }
        if(u[i]=='R'){
            if(wi[y[i]].size()>1){
                for(auto c:wi[y[i]]){
                    if(u[c]=='L'){
                        if(x[c]>x[i]){
                            crush = true;
                            time=min(time,5*(x[c]-x[i]));
                        }
                    }
                }
            }
        }
    }
    if(!crush){
        cout<<"SAFE"<<endl;
        return 0;
    }
    cout<<time<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:39: error: no matching function for call to 'min(int64_t&, int)'
   37 |                             time = min(time,10*(x[i]-x[c]));
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:37:39: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   37 |                             time = min(time,10*(x[i]-x[c]));
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:37:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   37 |                             time = min(time,10*(x[i]-x[c]));
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~
a.cc:47:39: error: no matching function for call to 'min(int64_t&, int)'
   47 |                             time = min(time,5*(y[c]-y[i]));
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:47:39: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   47 |                             time = min(time,5*(y[c]-y[i]));
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:47:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   47 |                             time = min(time,5*(y[c]-y[i]));
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~
a.cc:57:39: error: no matching function for call to 'min(int64_t&, int)'
   57 |                             time = min(time,10*(x[c]-x[i]));
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:57:39: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   57 |                             time = min(time,10*(x[c]-x[i]));
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:57:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   57 |                             time = min(time,10*(x[c]-x[i]));
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~
a.cc:69:39: error: no matching function for call to 'min(int64_t&, int)'
   69 |                             time = min(time,10*(x[i]-x[c]));
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:69:39: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   69 |                             time = min(time,10*(x[i]-x[c]));
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:69:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   69 |                             time = min(time,10*(x[i]-x[c]));
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~
a.cc:79:37: error: no matching function for call to 'min(int64_t&, int)'
   79 |                             time=min(time,10*(x[c]-x[i]));
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:79:37: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   79 |                             time=min(time,10*(x[c]-x[i]));
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:79:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   79 |                             time=min(time,10*(x[c]-x[i]));
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~
a.cc:91:37: error: no matching function for call to 'min(int64_t&, int)'
   91 |                             time=min(time,5*(x[c]-x[i]));
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _