QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#85948#141. 8 染色ExplodingKonjac0 19ms22508kbC++172.1kb2023-03-08 21:38:432023-03-08 21:38:46

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-08 21:38:46]
  • 评测
  • 测评结果:0
  • 用时:19ms
  • 内存:22508kb
  • [2023-03-08 21:38:43]
  • 提交

Alice

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

using LL=long long;
using LD=long double;
using UI=unsigned int;
using ULL=unsigned long long;

namespace
{

int deg[200005];
bool vis[200005];
vector<int> g[200005];

} // anonymous namespace

vector<int> Alice(int N,int M,vector<int> U,vector<int> V,vector<int> C)
{
	for(int i=0,u,v;i<M;i++)
	{
		u=U[i],v=V[i],deg[u]++,deg[v]++;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	queue<int> q;
	for(int i=0;i<N;i++) if(deg[i]<8) q.push(i),vis[i]=true;
	while(!q.empty())
	{
		int u=q.front();
		for(auto &v: g[u])
			if(!vis[v] && (--deg[v])<8)
				q.push(v),vis[v]=true;
		q.pop();
	}
	vector<int> res;
	for(int i=0;i<N;i++)
	{
		if(vis[i]) continue;
		res.push_back(C[i]&1);
		res.push_back(C[i]>>1&1);
	}
	return res;
}

Bob

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

using LL=long long;
using LD=long double;
using UI=unsigned int;
using ULL=unsigned long long;

namespace
{

int t,deg[200005],col[200005],id[200005];
bool vis[200005];
vector<int> g[200005];

} // anonymous namespace

vector<int> Bob(int N,int M,vector<int> U,vector<int> V,vector<int> X)
{
	for(int i=0,u,v;i<M;i++)
	{
		u=U[i],v=V[i],deg[u]++,deg[v]++;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	queue<int> q;
	for(int i=0;i<N;i++) if(deg[i]<8) q.push(i),vis[i]=true;
	vector<int> ord,ans(N);
	while(!q.empty())
	{
		int u=q.front();
		for(auto &v: g[u])
			if(!vis[v] && (--deg[v])<8)
				q.push(v),vis[v]=true;
		ord.push_back(u),q.pop();
	}
	for(int i=0;i<N;i++) if(!vis[i]) id[i]=t++;
	for(int i=0;i<t;i++) X[i]=X[i<<1]|(X[i<<1|1]<<1);
	fill(col,col+N,-1);
	function<void(int,int)> dfs=[&dfs,&X,&ans](int u,int c)
	{
		if(~col[u]) return;
		col[u]=c,ans[u]=X[id[u]]|(col[u]<<2);
		for(auto &v: g[u])
		{
			if(X[u]!=X[v]) continue;
			if(~col[v]) dfs(v,!c);
		}
	};
	for(int i=0;i<N;i++) dfs(i,0);
	reverse(ord.begin(),ord.end());
	for(auto &u: ord)
	{
		bool has[8]={false};
		for(auto &v: g[u])
		{
			if(vis[v]) continue;
			has[ans[v]]=true;
		}
		while(has[ans[u]]) ans[u]++;
		vis[u]=false;
	}
	return ans;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
+110000010011100010100101110010010010111000100111001011100110100111000101111010000111111111110111000110100010110011100100011011000111100001001111111111110101110011000001100110111101000000101001100000011101001111010100111011101001011110001011111010011010011001110100001001001100000011001011011...

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
3 0 0 2 0 3 1 0 1 1 2 2 3 0 1 2 0 1 3 1 0 1 2 3 0 1 3 1 2 1 1 2 3 0 2 2 3 1 1 0 2 3 3 3 3 3 2 3 0 2 1 1 0 1 3 0 3 1 2 0 2 1 3 0 2 3 1 0 2 0 3 3 3 3 3 3 2 2 3 0 3 0 0 2 1 2 1 3 3 2 0 0 0 1 1 2 1 0 0 2 3 2 0 3 3 2 2 0 3 1 3 1 1 2 2 3 1 0 1 3 3 1 1 2 1 1 2 1 2 3 2 0 0 1 2 0 3 0 0 0 3 0 1 3 2 3 ...

result:

wrong answer the color of the vertex 8535 and 3111 is the same