이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define rd() abs((int)rng())
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 2e4 + 100;
const int mod = 1e9 + 7;
namespace {
	int n, m, A, B;
	vector<int>U, V, label;
	vector<pii>adj[maxn];
	
	void solve1() {
		queue<int>Q;
		vector<int>dist(n, mod);
		dist[0] = 0;
		Q.push(0);
		while (sz(Q)) {
			int v = Q.front();
			Q.pop();
			for (pii to : adj[v]) {
				if (dist[to.x] > dist[v] + 1) {
					dist[to.x] = dist[v] + 1;
					Q.push(to.x);
				}
			}
		}
		for (int i = 0; i < m; i++) {
			label[i] = min(dist[V[i]], dist[U[i]]) % 3;
		}
	}
	string s = "010011";
	void dfs(int v, int p, int prev_label) {
		for (pii to : adj[v]) {
			if (to.x != p) {
				if (sz(adj[v]) > 2) {
					int new_label = (s[prev_label] - '0') ^ 1;
					label[to.y] = new_label;
					dfs(to.x, v, new_label);
				} else {
					int new_label = (prev_label + 1) % 6;
					label[to.y] = (s[new_label] - '0');
					dfs(to.x, v, new_label);
				}
			}
		}
	}
	void solve2() {
		dfs(0, 0, 0);
	}
	vector<int> solve(int N, int M, int AA, int BB, vector<int>UU, vector<int>VV) {
		n = N, m = M, A = AA, B = BB;
		U = UU, V = VV;
		label.resize(m);
		for (int i = 0; i < m; i++) {
			adj[U[i]].pb({V[i], i});
			adj[V[i]].pb({U[i], i});
		}
		if (A >= 3) {
			solve1();
		} else {
			solve2();
		}
		return label;
	}
}  // namespace
vector<int>Mark(int N, int M, int A, int B, vector<int>U, vector<int>V) {
	return solve(N, M, A, B, U, V);
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define rd() abs((int)rng())
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 2e4 + 100;
const int mod = 1e9 + 7;
namespace {
	int A, B;
	string cur;
	vector<int>moves;
	bool flag = false;
	int go(vector<int>y) {
		int cnt = y[0] + y[1];
		if (flag) {
			if (cnt == 1) {
				moves.pb((y[0] > 0 ? 0 : 1));
			} else {
				moves.pb(moves.back() ^ 1);
			}
		} else {
			if (cnt == 0) {
				flag = true;
				moves.pb(moves.back());
				return -1;
			}
			if (cnt == 1) {
				
				moves.pb((y[0] > 0 ? 0 : 1));
				goto done;
				if (!sz(moves)) {
					flag = true;
					moves.pb((y[0] > 0 ? 0 : 1));
				} else {
					if (sz(moves) < 4) {
						moves.pb((y[0] > 0 ? 0 : 1));
					} else {
						string t;
						for (int move : moves) {
							t += (move + '0');
						}
						t += (y[0] > 0 ? '0' : '1');
						string s = "110010";
						bool chk = false;
						for (int rot = 0; rot < 6; rot++) {
							if (s.substr(0, 5) == t) {
								chk = true;
							}
							rotate(t.begin(), t.begin() + 1, t.end());
						}
						flag = true;
						if (chk) {
							moves.pb(y[0] > 0 ? 0 : 1);
						} else {
							moves.pb(moves.back());
							return -1;
						}
					}
				}
			} else if (cnt == 2) {
				if (!sz(moves)) {
					if (y[0] && y[1]) {
						moves.pb(0), moves.pb(1);
					} else if (y[0] > 0) {
						moves.pb(0), moves.pb(0);
					} else {
						moves.pb(1), moves.pb(1);
					}
				} else {
					if (!y[0] || !y[1]) {
						flag = true;
						moves.pb(moves.back());
						return -1;
					} else {
						flag = true;
						moves.pb(moves.back() ^ 1);
					}
				}
			} else if (cnt >= 3) {
				flag = true;
				if (!sz(moves)) {
					moves.pb((y[0] == 1 ? 0 : 1));
				} else {
					if (!y[0] || !y[1]) {
						moves.pb(moves.back());
						return -1;
					} else {
						moves.pb(moves.back() ^ 1);
					}
				}
			}
		}
		done: ;
		return moves.back();
	}
}  // namespace
void Init(int A, int B) {
  ::A = A;
  ::B = B;
}
int Move(vector<int>y) {
	if (A >= 3) {
		for (int i = 0; i < 3; i++) {
			if (y[i] > 0 && y[(i + 1) % 3] > 0) {
				return i;
			}
		}
		for (int i = 0; i < 3; i++) {
			if (y[i] > 0) {
				return i;
			}
		}
	} else {
		return go(y);
	}
}
컴파일 시 표준 에러 (stderr) 메시지
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:129:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |