Language: C++

#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
typedef long long ll;
using namespace std;


int n, m, a, b;
string s;
vector<int>g[200000];
set<int>A, B;
set<pair<int, int>>c;
bool ab[2];
int v[200000];

bool dfs(int x,bool y,char z,int k) {
	v[x] = (k+1)%4;
	if (y&&z == 'A' || !y&&z == 'B') {
		lp(g[x].size()) {
			if (A.find(g[x][i]) != A.end()) {
				if(v[g[x][i]]){
					if (c.find(mkp(min(x, g[x][i]), max(x, g[x][i]))) == c.end()&&v[g[x][i]]==(k+1)%4)
						return true;
				}
				else {
					c.insert(mkp(min(x, g[x][i]), max(x, g[x][i])));
					if (y) {
						if (dfs(g[x][i], false, 'A'))
							return true;
					}
					else {
						if (dfs(g[x][i], true, 'A'))
							return true;
					}
				}
			}
		}
	}
	else {
		lp(g[x].size()) {
			if (B.find(g[x][i]) != B.end()) {
				if(v[g[x][i]]){
					if (c.find(mkp(min(x, g[x][i]), max(x, g[x][i]))) == c.end()v[g[x][i]] == (k + 1)%4)
						return true;
				}
				else {
					c.insert(mkp(min(x, g[x][i]), max(x, g[x][i])));
					if (y) {
						if (dfs(g[x][i], false, 'B'))
							return true;
					}
					else {
						if (dfs(g[x][i], true, 'B'))
							return true;
					}
				}
			}
		}
	}
	return false;
}



int main() {
	cin >> n >> m >> s;
	lp(m) {
		cin >> a >> b;
		g[a - 1].push_back(b - 1);
		g[b - 1].push_back(a - 1);
	}
	lp(n) {
		v[i] = -1;
		ab[0] = ab[1] = false;
		LP(g[i].size(),j) {
			if (s[g[i][j]] == 'A')
				ab[0] = true;
			else ab[1] = true;
		}
		if (ab[0] && ab[1]) {
			if (s[i] == 'A')A.insert(i);
			else B.insert(i);
		}
	}
	for (auto it = A.begin(); it != A.end(); it++) {
		cout << *it << endl;
		if(v[*it]==-1)
			if (dfs(*it,true,'A',0)) {
				cout << "Yes" << endl;
				return 0;
			}
	}
	cout << "No" << endl;
	return 0;
}


Compiler output:
a.cc: In function 'bool dfs(int, bool, char, int)':
a.cc:46:56: error: too few arguments to function 'bool dfs(int, bool, char, int)'
   46 |                                                 if (dfs(g[x][i], false, 'A'))
      |                                                     ~~~^~~~~~~~~~~~~~~~~~~~~
a.cc:34:6: note: declared here
   34 | bool dfs(int x,bool y,char z,int k) {
      |      ^~~
a.cc:50:56: error: too few arguments to function 'bool dfs(int, bool, char, int)'
   50 |                                                 if (dfs(g[x][i], true, 'A'))
      |                                                     ~~~^~~~~~~~~~~~~~~~~~~~
a.cc:34:6: note: declared here
   34 | bool dfs(int x,bool y,char z,int k) {
      |      ^~~
a.cc:61:101: error: expected ')' before 'v'
   61 |                                         if (c.find(mkp(min(x, g[x][i]), max(x, g[x][i]))) == c.end()v[g[x][i]] == (k + 1)%4)
      |                                            ~                                                        ^
      |                                                                                                     )
a.cc:67:56: error: too few arguments to function 'bool dfs(int, bool, char, int)'
   67 |                                                 if (dfs(g[x][i], false, 'B'))
      |                                                     ~~~^~~~~~~~~~~~~~~~~~~~~
a.cc:34:6: note: declared here
   34 | bool dfs(int x,bool y,char z,int k) {
      |      ^~~
a.cc:71:56: error: too few arguments to function 'bool dfs(int, bool, char, int)'
   71 |                                                 if (dfs(g[x][i], true, 'B'))
      |                                                     ~~~^~~~~~~~~~~~~~~~~~~~
a.cc:34:6: note: declared here
   34 | bool dfs(int x,bool y,char z,int k) {
      |      ^~~