Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll p=1000000;
ll e(ll a, ll b){
    return a*p+b;
}

ll edges[400001];
int checked[400001];
int phase[400001];
vector<int> v[200001];
    
int main(){
    int N, M;
    cin >> N >> M;
    string s;
    cin >> s;

    unordered_map<ll,int> edge2idx;
    for(int i=1;i<=M;i++){
        int a,b;
        cin >> a >> b;

        edges[2*i]=e(a,b);
        edges[2*i+1]=e(b,a);
        
        checked[2*i]=0;
        checked[2*i+1]=0;
        phase[2*i]=INT32_MAX;
        phase[2*i+1]=INT32_MAX;
        
        if(edge2idx[e(a,b)]==0){
            edge2idx[e(a,b)]=2*i;
            v[a].push_back(b);
        }
        else checked[2*i]=-1;

        if(edge2idx[e(b,a)]==0){
            edge2idx[e(b,a)]=2*i+1;
            v[b].push_back(a);
        }
        else checked[2*i+1]=-1;
    }
    int turn=1;
    for(int i=1;i<=M;i++){
        queue<pair<pair<int,ll>,unordered_set<ll>>> cur;
        if(s[edges[i]/p-1]!='A' || s[edges[i]%p-1]!='A' || checked[i]!=0) continue;
        set<ll> set_e;
        set_e.insert(edges[i]);
        cur.push(make_pair(make_pair(0,edges[i]),set_e));
        checked[i]=turn;
        phase[i]=0;
        while(!cur.empty()){
            pair<int,ll> t=cur.front().first;
            set<ll> set_tp=cur.front().second;
            cur.pop();
            for(int to:v[t.second%p]){
                if((t.first%4<2)==(s[to-1]=='A')) continue;
                if(checked[edge2idx[e(t.second%p,to)]]!=0){
                    if(checked[edge2idx[e(t.second%p,to)]]==turn && phase[edge2idx[e(t.second%p,to)]]<t.first+1){
                        if(set_tp.count(e(t.second%p,to))>0){
                            cout << "Yes" << endl;
                            return 0;
                        }else{
                            continue;
                        }
                    }else{
                        continue;
                    }
                }
                set_tp.insert(e(t.second%p,to));
                cur.push(make_pair(make_pair(t.first+1,e(t.second%p,to)),set_tp));
                phase[edge2idx[e(t.second%p,to)]]=t.first+1;
                checked[edge2idx[e(t.second%p,to)]]=turn;
            }
        }
        turn++;
    }
    cout << "No" << endl;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:54:17: error: no matching function for call to 'std::queue<std::pair<std::pair<int, long long int>, std::unordered_set<long long int> > >::push(std::pair<std::pair<int, long long int>, std::set<long long int> >)'
   54 |         cur.push(make_pair(make_pair(0,edges[i]),set_e));
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h:283:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<std::pair<int, long long int>, std::unordered_set<long long int> >; _Sequence = std::deque<std::pair<std::pair<int, long long int>, std::unordered_set<long long int> >, std::allocator<std::pair<std::pair<int, long long int>, std::unordered_set<long long int> > > >; value_type = std::pair<std::pair<int, long long int>, std::unordered_set<long long int> >]'
  283 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:283:30: note:   no known conversion for argument 1 from 'std::pair<std::pair<int, long long int>, std::set<long long int> >' to 'const std::queue<std::pair<std::pair<int, long long int>, std::unordered_set<long long int> > >::value_type&' {aka 'const std::pair<std::pair<int, long long int>, std::unordered_set<long long int> >&'}
  283 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:288:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(value_type&&) [with _Tp = std::pair<std::pair<int, long long int>, std::unordered_set<long long int> >; _Sequence = std::deque<std::pair<std::pair<int, long long int>, std::unordered_set<long long int> >, std::allocator<std::pair<std::pair<int, long long int>, std::unordered_set<long long int> > > >; value_type = std::pair<std::pair<int, long long int>, std::unordered_set<long long int> >]'
  288 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:288:25: note:   no known conversion for argument 1 from 'std::pair<std::pair<int, long long int>, std::set<long long int> >' to 'std::queue<std::pair<std::pair<int, long long int>, std::unordered_set<long long int> > >::value_type&&' {aka 'std::pair<std::pair<int, long long int>, std::unordered_set<long long int> >&&'}
  288 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
a.cc:59:40: error: conversion from 'std::unordered_set<long long int>' to non-scalar type 'std::set<long long int>' requested
   59 |             set<ll> set_tp=cur.front().second;
      |                            ~~~~~~~~~~~~^~~~~~
a.cc:76:25: error: no matching function for call to 'std::queue<std::pair<std::pair<int, long long int>, std::unordered_set<long long int> > >::push(std::pair<std::pair<int, long long int>, std::set<long long int> >)'
   76 |                 cur.push(make_pair(make_pair(t.first+1,e(t.second%p,to)),set_tp));
      |                 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:283:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<std::pair<int, long long int>, std::unordered_set<long long int> >; _Sequence = std::deque<std::pair<std::pair<int, long long int>, std::unordered_set<long long int> >, std::allocator<std::pair<std::pair<int, long long int>, std::unordered_set<long long int> > > >; value_type = std::pair<std::pair<int, long long int>, std::unordered_set<long long int> >]'
  283 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:283:30: note:   no known conversion for argument 1 from 'std::pair<std::pair<int, long long int>, std::set<long long int> >' to 'const std::queue<std::pair<std::pair<int, long long int>, std::unordered_set<long long int> > >::value_type&' {aka 'const std::pair<std::pair<int, long long int>, std::unordered_set<long long int> >&'}
  283 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:288:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(value_type&&) [with _Tp = std::pair<std::pair<int, long long int>, std::unordered_set<long long int> >; _Sequence = std::deque<std::pair<std::pair<int, long long int>, std::unordered_set<long long int> >, std::allocator<std::pair<std::pair<int, long long int>, std::unordered_set<long long int> > > >; value_type = std::pair<std::pair<int, long long int>, std::unordered_set<long long int> >]'
  288 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:288:25: note:   no known conversion for argument 1 from 'std::pair<std::pair<int, long long int>, std::set<long long int> >' to 'std::queue<std::pair<std::pair<int, long long int>, std::unordered_set<long long int> > >::value_type&&' {aka 'std::pair<std::pair<int, long long int>, std::unordered_set<long long int> >&&'}
  288 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~