Language: C++

#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	int N, M, T;
	cin >> N >> M >> T;
	if(T == 1) {
		uint64_t bits[50000][50000/64+1];
		memset(bits, 0, sizeof(bits));
		for(int i = 0; i < N; i++) bits[i][i>>6] |= 1ULL<<(i&63);
		for(int j = 0; j < N; j++)
			for(int i = N; i < (N/64+1)*64; i++) bits[j][i>>6] |= 1ULL<<(i&63);
		vector< vector< pair<int, int> > > bal(N);
		int final = -1;
		for(int i = 0; i < M; i++) {
			int x, y;
			// cin >> x >> y;
			x = 1, y = 2;
			bal[--x].push_back({--y, i+1});
			bal[y].push_back({x, -(i+1)});
			if(final != -1) continue;
			uint64_t * __restrict ptr_x = bits[x];
			uint64_t * __restrict ptr_y = bits[y];
			uint64_t * __restrict ptr_fin = ptr_x + (N/64+1);
			uint64_t done = -1;
			for(; ptr_x != ptr_fin; ptr_x++, ptr_y++) {
				uint64_t v = *ptr_x | *ptr_y;
				*ptr_x = *ptr_y = v;
				done &= v;
			}
			if(!(~done)) final = x;
		}
		if(final == -1) {
			cout << "-1\n";
			return 0;
		}
		string ans;
		for(int i = 0; i < M; i++) ans += '.';
		vector<int> order(N, -1);
		order[final] = 0;
		vector<int> q = {final};
		for(int i = 0; i < N; i++) for(auto p : bal[q[i]]) {
			int x = p.first, y = p.second;
			if(order[x] == -1) {
				order[x] = q.size();
				q.push_back(x);
			}
			if(order[x] > order[i] && id > 0) ans[id-1] = '^';
			if(order[x] > order[i] && id < 0) ans[-(id-1)] = 'v';
			if(order[x] < order[i] && id > 0) ans[id-1] = 'v';
			if(order[x] < order[i] && id < 0) ans[-(id-1)] = '^';
		}
		cout << ans << "\n";
		return 0;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:17: error: 'uint64_t' was not declared in this scope
   12 |                 uint64_t bits[50000][50000/64+1];
      |                 ^~~~~~~~
a.cc:4:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
    3 | #include <cstring>
  +++ |+#include <cstdint>
    4 | using namespace std;
a.cc:13:24: error: 'bits' was not declared in this scope
   13 |                 memset(bits, 0, sizeof(bits));
      |                        ^~~~
a.cc:26:36: error: expected primary-expression before '__restrict'
   26 |                         uint64_t * __restrict ptr_x = bits[x];
      |                                    ^~~~~~~~~~
a.cc:27:36: error: expected primary-expression before '__restrict'
   27 |                         uint64_t * __restrict ptr_y = bits[y];
      |                                    ^~~~~~~~~~
a.cc:28:36: error: expected primary-expression before '__restrict'
   28 |                         uint64_t * __restrict ptr_fin = ptr_x + (N/64+1);
      |                                    ^~~~~~~~~~
a.cc:29:33: error: expected ';' before 'done'
   29 |                         uint64_t done = -1;
      |                                 ^~~~~
      |                                 ;
a.cc:30:31: error: 'ptr_x' was not declared in this scope
   30 |                         for(; ptr_x != ptr_fin; ptr_x++, ptr_y++) {
      |                               ^~~~~
a.cc:30:40: error: 'ptr_fin' was not declared in this scope
   30 |                         for(; ptr_x != ptr_fin; ptr_x++, ptr_y++) {
      |                                        ^~~~~~~
a.cc:30:58: error: 'ptr_y' was not declared in this scope
   30 |                         for(; ptr_x != ptr_fin; ptr_x++, ptr_y++) {
      |                                                          ^~~~~
a.cc:31:41: error: expected ';' before 'v'
   31 |                                 uint64_t v = *ptr_x | *ptr_y;
      |                                         ^~
      |                                         ;
a.cc:32:51: error: 'v' was not declared in this scope
   32 |                                 *ptr_x = *ptr_y = v;
      |                                                   ^
a.cc:33:33: error: 'done' was not declared in this scope
   33 |                                 done &= v;
      |                                 ^~~~
a.cc:35:31: error: 'done' was not declared in this scope
   35 |                         if(!(~done)) final = x;
      |                               ^~~~
a.cc:52:51: error: 'id' was not declared in this scope; did you mean 'i'?
   52 |                         if(order[x] > order[i] && id > 0) ans[id-1] = '^';
      |                                                   ^~
      |                                                   i
a.cc:53:51: error: 'id' was not declared in this scope; did you mean 'i'?
   53 |                         if(order[x] > order[i] && id < 0) ans[-(id-1)] = 'v';
      |                                                   ^~
      |                                                   i
a.cc:54:51: error: 'id' was not declared in this scope; did you mean 'i'?
   54 |                         if(order[x] < order[i] && id > 0) ans[id-1] = 'v';
      |                                                   ^~
      |                                                   i
a.cc:55:51: error: 'id' was not declared in this scope; did you mean 'i'?
   55 |                         if(order[x] < order[i] && id < 0) ans[-(id-1)] = '^';
      |                                                   ^~
      |                                                   i