Submission #670637

# Submission time Handle Problem Language Result Execution time Memory
670637 2022-12-09T19:24:28 Z rainboy Stray Cat (JOI20_stray) C++17
Compilation error
0 ms 0 KB
#include "Anthony.h"
#include <cstdlib>
#include <vector>

using namespace std;

typedef vector<int> vi;

namespace A {
	const int N = 20000;
	const int zz[] = { 0, 1, 0, 0, 1, 1 };

	int min(int a, int b) { return a < b ? a : b; }

	int *ej[N], eo[N], dd[N], pp[N], cc_[N], qu[N], n;

	void init(int n_) {
		n = n_;
		for (int i = 0; i < n; i++)
			ej[i] = (int *) malloc(2 * sizeof *ej[i]);
	}

	void append(int i, int j) {
		int o = eo[i]++;
		if (o >= 2 && (o & o - 1) == 0)
			ej[i] = (int *) realloc(ej[i], o * 2 * sizeof *ej[i]);
		ej[i][o] = j;
	}

	void bfs() {
		for (int i = 0; i < n; i++)
			dd[i] = n;
		int cnt = 0;
		dd[0] = 0, qu[cnt++] = 0;
		for (int h = 0; h < cnt; h++) {
			int i = qu[h], d = dd[i] + 1;
			for (int o = eo[i]; o--; ) {
				int j = ej[i][o];
				if (dd[j] > d)
					dd[j] = d, qu[cnt++] = j;
			}
		}
	}
	void dfs(int p, int i, int c) {
		pp[i] = p;
		for (int o = eo[i]; o--; ) {
			int j = ej[i][o];
			if (j != p) {
				if (p == -1)
					cc_[j] = 0, dfs(i, j, 0);
				else if (eo[i] == 2)
					cc_[j] = zz[(c + 1) % 6], dfs(i, j, (c + 1) % 6);
				else
					cc_[j] = zz[c % 6] ^ 1, dfs(i, j, zz[c % 6] ^ 1);
			}
		}
	}
}

vi Mark(int n, int m, int a, int b, vi uu, vi vv) {
	vi cc(m);
	if (a >= 3 && b == 0) {
		A::init(n);
		for (int h = 0; h < m; h++)
			A::append(uu[h], vv[h]), A::append(vv[h], uu[h]);
		A::bfs();
		for (int h = 0; h < m; h++)
			cc[h] = A::min(A::dd[uu[h]], A::dd[vv[h]]) % 3;
	} else {
		A::init(n);
		for (int h = 0; h < m; h++)
			A::append(uu[h], vv[h]), A::append(vv[h], uu[h]);
		A::dfs(-1, 0, -1);
		for (int h = 0; h < m; h++) {
			int i = A::pp[uu[h]] == vv[h] ? uu[h] : vv[h];
			cc[h] = A::cc_[i];
		}
	}
	return cc;
}
#include "Anthony.h"
#include <cstdlib>
#include <vector>

using namespace std;

typedef vector<int> vi;

namespace A {
	const int N = 20000;
	const int zz[] = { 0, 1, 0, 0, 1, 1 };

	int min(int a, int b) { return a < b ? a : b; }

	int *ej[N], eo[N], dd[N], pp[N], cc_[N], qu[N], n;

	void init(int n_) {
		n = n_;
		for (int i = 0; i < n; i++)
			ej[i] = (int *) malloc(2 * sizeof *ej[i]);
	}

	void append(int i, int j) {
		int o = eo[i]++;
		if (o >= 2 && (o & o - 1) == 0)
			ej[i] = (int *) realloc(ej[i], o * 2 * sizeof *ej[i]);
		ej[i][o] = j;
	}

	void bfs() {
		for (int i = 0; i < n; i++)
			dd[i] = n;
		int cnt = 0;
		dd[0] = 0, qu[cnt++] = 0;
		for (int h = 0; h < cnt; h++) {
			int i = qu[h], d = dd[i] + 1;
			for (int o = eo[i]; o--; ) {
				int j = ej[i][o];
				if (dd[j] > d)
					dd[j] = d, qu[cnt++] = j;
			}
		}
	}
	void dfs(int p, int i, int c) {
		pp[i] = p;
		for (int o = eo[i]; o--; ) {
			int j = ej[i][o];
			if (j != p) {
				if (p == -1)
					cc_[j] = 0, dfs(i, j, 0);
				else if (eo[i] == 2)
					cc_[j] = zz[(c + 1) % 6], dfs(i, j, (c + 1) % 6);
				else
					cc_[j] = zz[c % 6] ^ 1, dfs(i, j, zz[c % 6] ^ 1);
			}
		}
	}
}

vi Mark(int n, int m, int a, int b, vi uu, vi vv) {
	vi cc(m);
	if (a >= 3 && b == 0) {
		A::init(n);
		for (int h = 0; h < m; h++)
			A::append(uu[h], vv[h]), A::append(vv[h], uu[h]);
		A::bfs();
		for (int h = 0; h < m; h++)
			cc[h] = A::min(A::dd[uu[h]], A::dd[vv[h]]) % 3;
	} else {
		A::init(n);
		for (int h = 0; h < m; h++)
			A::append(uu[h], vv[h]), A::append(vv[h], uu[h]);
		A::dfs(-1, 0, -1);
		for (int h = 0; h < m; h++) {
			int i = A::pp[uu[h]] == vv[h] ? uu[h] : vv[h];
			cc[h] = A::cc_[i];
		}
	}
	return cc;
}

Compilation message

Anthony.cpp: In function 'void A::append(int, int)':
Anthony.cpp:25:24: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   25 |   if (o >= 2 && (o & o - 1) == 0)
      |                      ~~^~~

Catherine.cpp: In function 'void A::append(int, int)':
Catherine.cpp:25:24: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   25 |   if (o >= 2 && (o & o - 1) == 0)
      |                      ~~^~~
/usr/bin/ld: /tmp/ccFNufB0.o: in function `main':
grader_catherine.cpp:(.text.startup+0x41c): undefined reference to `Init(int, int)'
/usr/bin/ld: grader_catherine.cpp:(.text.startup+0xcfa): undefined reference to `Move(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status