QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#167189#141. 8 染色training4usacoCompile Error//C++171.9kb2023-09-07 12:01:102023-09-07 12:01:10

Judging History

你现在查看的是最新测评结果

  • [2023-09-07 12:01:10]
  • 评测
  • [2023-09-07 12:01:10]
  • 提交

Alice

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

// #define int long long
const int MAXN = 2e5 + 5;

int deg[MAXN];

vector<int> Alice(int n, int m, vector<int> U, vector<int> V, vector<int> c) {
	vector<int> ret;

	for(int i = 0; i < m; ++i) {
		++deg[U[i] + 1]; ++deg[V[i] + 1];
	}

	for(int i = 1; i <= n; ++i) {
		if(deg[i] < 8) continue;

		if(c[i - 1] <= 1) {
			ret.push_back(0); ret.push_back(0);
		}
		else if(c[i - 1] <= 3) {
			ret.push_back(0); ret.push_back(1);
		}
		else if(c[i - 1] <= 5) {
			ret.push_back(1); ret.push_back(0);
		}
		else if(c[i - 1] <= 7) {
			ret.push_back(1); ret.push_back(1);
		}
	}
	return ret;
}

Bob

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

// #define int long long
const int MAXN = 2e5 + 5;

int val[MAXN], deg[MAXN], color[MAXN];
bool vis[MAXN];
vector<int> adj[MAXN];
// vector<bool> temp;

void dfs(int u, int c) {
	if(vis[u]) return;
	vis[u] = true;
	color[u] = c;

	for(auto v : adj[u]) {
		if(val[u] == val[v]) dfs(v, c ^ 1);
	}
}

vector<int> Bob(int n, int m, vector<int> U, vector<int> V, vector<int> x) {
	for(int i = 0; i < m; ++i) {
		int a = U[i] + 1, b = V[i] + 1;
		++deg[a]; ++deg[b];
		adj[a].push_back(b); adj[b].push_back(a);
	}

	int idx = 0;
	for(int i = 1; i <= n; ++i) {
		if(deg[i] < 8) continue;

		val[i] = (2 * x[idx++]) + (x[idx++] + 1);
	}

	for(int i = 1; i <= n; ++i) {
		if(val[i] == 0 || vis[i]) continue;
		dfs(i, 0);
	}

	vector<int> ans(n);
	for(int i = 1; i <= n; ++i) {
		if(val[i] == 0) {
			temp.clear();
			for(int j = 0; j < 8; ++j) vis[j] = false;

			for(auto v : adj[i]) {
				if(val[v]) {
					vis[2 * (val[v] - 1) + color[v]] = true;
				}
			}

			for(int j = 0; j < 8; ++j) {
				if(vis[j]) continue;
				ans[i - 1] = j;
				color[i] = j;
				val[i] = 1;
			}
		}
		else {
			ans[i - 1] = 2 * (val[i] - 1) + color[i];
		}
	}

	return ans;
}

Details

Bob.code: In function ‘std::vector<int> Bob(int, int, std::vector<int>, std::vector<int>, std::vector<int>)’:
Bob.code:45:25: error: ‘temp’ was not declared in this scope; did you mean ‘tm’?
   45 |                         temp.clear();
      |                         ^~~~
      |                         tm