QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#84565#141. 8 染色Ignotus0 19ms22964kbC++141.6kb2023-03-06 15:54:552023-03-06 15:54:56

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-06 15:54:56]
  • 评测
  • 测评结果:0
  • 用时:19ms
  • 内存:22964kb
  • [2023-03-06 15:54:55]
  • 提交

Alice

#include <bits/stdc++.h>
#include "Alice.h"

const int MX = 2e5 + 10;

int deg[MX];

std::vector <int> Alice(int N, int M, std::vector <int> U, std::vector <int> V, std::vector <int> C) {
	for(int i = 0; i < M; ++i) ++deg[U[i]], ++deg[V[i]];
	std::vector <int> ret;
	for(int i = 0; i < N; ++i) if(deg[i] >= 8) ret.push_back(C[i] >> 2 & 1), ret.push_back(C[i] >> 1 & 1);
	return ret;
}

Bob

#include <bits/stdc++.h>
#include "Bob.h"

const int MX = 2e5 + 10;

std::vector <int> G[MX];
int n, m, bl[MX], col[MX], deg[MX];

void bfs(int S, int c){
	std::queue <int> q;
	q.push(S), col[S] = 2 * c;
	while(q.size()){
		int x = q.front(); q.pop();
		for(auto y : G[x]) if(bl[y] == c && col[y] == -1) col[y] = col[x] ^ 1, q.push(y);
	}
}

void paint(int c){
	for(int i = 0; i < n; ++i) if(bl[i] == c && col[i] == -1) bfs(i, c);
}

std::vector <int> Bob(int N, int M, std::vector <int> U, std::vector <int> V, std::vector <int> X) {
	n = N, m = M;
	for(int i = 0; i < m; ++i){
		G[U[i]].push_back(V[i]), G[V[i]].push_back(U[i]);
		++deg[U[i]], ++deg[V[i]];
	}
	for(int i = 0; i < n; ++i) bl[i] = -1, col[i] = -1;
	int cur = 0, sizx = X.size();
	for(int i = 0; i < sizx; i += 2){
		while(cur < N - 1 && deg[cur] < 8) ++cur;
		bl[cur] = 2 * X[i] + X[i + 1];
	}
	for(int i = 0; i < 4; ++i) paint(i);
	for(int i = 0; i < n; ++i){
		if(deg[i] >= 8) continue;
		static bool vis[8];
		memset(vis, 0, sizeof vis);
		for(auto y : G[i]) if(col[y] != -1) vis[col[y]] = 1;
		for(int j = 0; j < 8; ++j) if(!vis[j]){
			col[i] = j;
			break;
		}
	}
	std::vector <int> ret;
	for(int i = 0; i < n; ++i) ret.push_back(col[i]);
	return ret;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 19ms
memory: 22964kb

input:

10000 500000
5247 482
4774 3796
5245 9386
8794 2818
1911 3240
6925 6008
6313 1737
8668 4913
7892 5444
6740 2271
2100 53
8527 9605
4009 4765
5293 2683
6552 1326
8877 9929
402 9849
8664 6893
1998 7305
155 9477
9753 8036
448 5438
8535 3111
9493 406
7694 2030
5745 6890
5519 3106
8979 5098
9948 2453
5601...

output:

Success
0100001110010010000001010100000110001100100011110010010001001001010001011100001011110111110101110001101010100100111011001100111001010010011011010101010111010100011010110011101101110010100000011000000101110011010101100100110010110111101010111100001110001110010101100000111011100010011000111111...

input:

10000 500000
5247 482
4774 3796
5245 9386
8794 2818
1911 3240
6925 6008
6313 1737
8668 4913
7892 5444
6740 2271
2100 53
8527 9605
4009 4765
5293 2683
6552 1326
8877 9929
402 9849
8664 6893
1998 7305
155 9477
9753 8036
448 5438
8535 3111
9493 406
7694 2030
5745 6890
5519 3106
8979 5098
9948 2453
5601...

output:

Failed
the elements of C should be between 0 and 7

result:

wrong answer invalid communication process!