Language: C++

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}

void solve(){


}
vector<bitset<50009>> b;
int x[100009],y[100009];
int val[500009];
int lol[3][3];
int b[500009];
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	int n,m,t;cin>>n>>m>>t;
	b.resize(n);
	rep(i,n) {
			b[i].set();
			b[i][i]=0;
	}
	vi gg;
	rep(q,m){
		cin>>x[q]>>y[q];
		x[q]--,y[q]--;
		if(t==1) b[x[q]]=b[y[q]]=(b[x[q]]&b[y[q]]);
		else{
			b[x[q]][y[q]]=b[y[q]][x[q]]=0;
			if(x[q]<3&&y[q]<3) lol[x[q]][y[q]]=lol[y[q]][x[q]] = q;
		}
	}
	int ans = -1,ans2;
	rep(i,n){
		if(b[i]._Find_first()!=n&&t==2){
			ans=i;
			ans2 = b[i]._Find_first();
			break;
		}
		if(b[i]._Find_first()==n&&t==1){
			ans=i;
			break;
		}
	}
	if(ans==-1&&(t==1||n==2)){
		cout<<-1;
	}
	else if(ans==-1){
		string fns;
		rep(i,n) val[i]=1,b[i]=1;
		rep(i,m){
			if(val[b[x[i]]]>val[b[y[i]]]){
				val[b[x[i]]]--;
				b[x[i]]=b[y[i]];
				val[b[x[i]]]++;
				fns+="^";
			}
			else{
				swap(x[i],y[i]);
				val[b[x[i]]]--;
				b[x[i]]=b[y[i]];
				val[b[x[i]]]++;
				fns+="v";
			
			}
		}
		cout<<fns;
	}
	else{
		string fns;
		val[ans]=1;
		int c=2;
		if(t==2) val[ans2]=c++;
		repD(i,m-1,0){
			if(val[x[i]]==0&&val[y[i]]!=0){
				fns+="v";
				val[x[i]] = c++;
			}
			else if(val[y[i]]==0&&val[x[i]]!=0){
				fns+="^";
				val[y[i]]=c++;
			}
			else if(val[x[i]]<val[y[i]]){
				fns+="^";
			}
			else fns+="v";
		}
		reverse(all(fns));
		cout<<fns;
	}
	return 0;
}



Compiler output:
a.cc:61:5: error: conflicting declaration 'int b [500009]'
   61 | int b[500009];
      |     ^
a.cc:57:23: note: previous declaration as 'std::vector<std::bitset<50009> > b'
   57 | vector<bitset<50009>> b;
      |                       ^
a.cc: In function 'int main()':
a.cc:101:31: error: no match for 'operator[]' (operand types are 'int [500009]' and '__gnu_cxx::__alloc_traits<std::allocator<std::bitset<50009> >, std::bitset<50009> >::value_type' {aka 'std::bitset<50009>'})
  101 |                         if(val[b[x[i]]]>val[b[y[i]]]){
      |                               ^
a.cc:101:44: error: no match for 'operator[]' (operand types are 'int [500009]' and '__gnu_cxx::__alloc_traits<std::allocator<std::bitset<50009> >, std::bitset<50009> >::value_type' {aka 'std::bitset<50009>'})
  101 |                         if(val[b[x[i]]]>val[b[y[i]]]){
      |                                            ^
a.cc:102:36: error: no match for 'operator[]' (operand types are 'int [500009]' and '__gnu_cxx::__alloc_traits<std::allocator<std::bitset<50009> >, std::bitset<50009> >::value_type' {aka 'std::bitset<50009>'})
  102 |                                 val[b[x[i]]]--;
      |                                    ^
a.cc:104:36: error: no match for 'operator[]' (operand types are 'int [500009]' and '__gnu_cxx::__alloc_traits<std::allocator<std::bitset<50009> >, std::bitset<50009> >::value_type' {aka 'std::bitset<50009>'})
  104 |                                 val[b[x[i]]]++;
      |                                    ^
a.cc:109:36: error: no match for 'operator[]' (operand types are 'int [500009]' and '__gnu_cxx::__alloc_traits<std::allocator<std::bitset<50009> >, std::bitset<50009> >::value_type' {aka 'std::bitset<50009>'})
  109 |                                 val[b[x[i]]]--;
      |                                    ^
a.cc:111:36: error: no match for 'operator[]' (operand types are 'int [500009]' and '__gnu_cxx::__alloc_traits<std::allocator<std::bitset<50009> >, std::bitset<50009> >::value_type' {aka 'std::bitset<50009>'})
  111 |                                 val[b[x[i]]]++;
      |                                    ^