QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#87380#141. 8 染色AFewSuns0 17ms31584kbC++144.6kb2023-03-12 19:29:022023-03-12 19:29:06

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-12 19:29:06]
  • Judged
  • Verdict: 0
  • Time: 17ms
  • Memory: 31584kb
  • [2023-03-12 19:29:02]
  • Submitted

Alice

#include "Alice.h"
#include<bits/stdc++.h>
using namespace std;
namespace my_std{
	#define ll long long
	#define bl bool
	ll my_pow(ll a,ll b,ll mod){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res=(res*a)%mod;
			a=(a*a)%mod;
			b>>=1;
		}
		return res;
	}
	ll qpow(ll a,ll b){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res*=a;
			a*=a;
			b>>=1;
		}
		return res;
	}
	#define db double
	#define pf printf
	#define pc putchar
	#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
	#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
	#define go(u) for(ll i=head[u];i;i=e[i].nxt)
	#define enter pc('\n')
	#define space pc(' ')
	#define fir first
	#define sec second
	#define MP make_pair
	#define il inline
	#define inf 8e18
	#define random(x) rand()*rand()%(x)
	#define inv(a,mod) my_pow((a),(mod-2),(mod))
	il ll read(){
		ll sum=0,f=1;
		char ch=0;
		while(!isdigit(ch)){
			if(ch=='-') f=-1;
			ch=getchar();
		}
		while(isdigit(ch)){
			sum=sum*10+(ch^48);
			ch=getchar();
		}
		return sum*f;
	}
	il void write(ll x){
		if(x<0){
			x=-x;
			pc('-');
		}
		if(x>9) write(x/10);
		pc(x%10+'0');
	}
	il void writeln(ll x){
		write(x);
		enter;
	}
	il void writesp(ll x){
		write(x);
		space;
	}
}
using namespace my_std;
vector<int> ans;
ll n,head[200020],cnt=0,d[200020];
bl ck[200020];
queue<ll> q;
struct node{
	ll nxt,to;
}e[1000010];
void add(ll u,ll v){
	e[++cnt].nxt=head[u];
	e[cnt].to=v;
	head[u]=cnt;
}
vector<int> Alice(int N,int M,vector<int> U,vector<int> V,vector<int> C){
	n=N;
	fr(i,0,M-1){
		add(U[i]+1,V[i]+1);
		add(V[i]+1,U[i]+1);
		d[U[i]+1]++;
		d[V[i]+1]++;
	}
	fr(i,1,n){
		if(d[i]<8){
			q.push(i);
			ck[i]=1;
		}
	}
	while(!q.empty()){
		ll u=q.front();
		q.pop();
		go(u){
			ll v=e[i].to;
			if(ck[v]) continue;
			d[v]--;
			if(d[v]<8){
				ck[v]=1;
				q.push(v);
			}
		}
	}
	fr(i,1,n){
		if(!ck[i]){
			ans.push_back(C[i-1]>>2);
			ans.push_back((C[i-1]>>1)&1);
		}
	}
	return ans;
}

Bob

#include "Bob.h"
#include<bits/stdc++.h>
using namespace std;
namespace my_std{
	#define ll long long
	#define bl bool
	ll my_pow(ll a,ll b,ll mod){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res=(res*a)%mod;
			a=(a*a)%mod;
			b>>=1;
		}
		return res;
	}
	ll qpow(ll a,ll b){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res*=a;
			a*=a;
			b>>=1;
		}
		return res;
	}
	#define db double
	#define pf printf
	#define pc putchar
	#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
	#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
	#define go(u) for(ll i=head[u];i;i=e[i].nxt)
	#define enter pc('\n')
	#define space pc(' ')
	#define fir first
	#define sec second
	#define MP make_pair
	#define il inline
	#define inf 8e18
	#define random(x) rand()*rand()%(x)
	#define inv(a,mod) my_pow((a),(mod-2),(mod))
	il ll read(){
		ll sum=0,f=1;
		char ch=0;
		while(!isdigit(ch)){
			if(ch=='-') f=-1;
			ch=getchar();
		}
		while(isdigit(ch)){
			sum=sum*10+(ch^48);
			ch=getchar();
		}
		return sum*f;
	}
	il void write(ll x){
		if(x<0){
			x=-x;
			pc('-');
		}
		if(x>9) write(x/10);
		pc(x%10+'0');
	}
	il void writeln(ll x){
		write(x);
		enter;
	}
	il void writesp(ll x){
		write(x);
		space;
	}
}
using namespace my_std;
vector<int> ans;
ll n,head[200020],cnt=0,d[200020];
ll id[200020],tot=0,blg[200020];
bl ck[200020],vis[200020],pd[9];
queue<ll> q;
struct node{
	ll nxt,to;
}e[1000010];
void add(ll u,ll v){
	e[++cnt].nxt=head[u];
	e[cnt].to=v;
	head[u]=cnt;
}
vector<int> Bob(int N,int M,vector<int> U,vector<int> V,vector<int> X){
	n=N;
	fr(i,0,M-1){
		add(U[i]+1,V[i]+1);
		add(V[i]+1,U[i]+1);
		d[U[i]+1]++;
		d[V[i]+1]++;
	}
	fr(i,1,n){
		if(d[i]<8){
			q.push(i);
			ck[i]=1;
		}
	}
	while(!q.empty()){
		ll u=q.front();
		q.pop();
		id[++tot]=u;
		go(u){
			ll v=e[i].to;
			if(ck[v]) continue;
			d[v]--;
			if(d[v]<8){
				ck[v]=1;
				q.push(v);
			}
		}
	}
	ll now=0;
	fr(i,1,n){
		if(ck[i]) continue;
		blg[i]=(X[now]<<1)|X[now+1];
		now+=2;
	}
	ans.resize(n);
	fr(k,0,3){
		fr(s,1,n){
			if(ck[s]||vis[s]||blg[s]!=k) continue;
			q.push(s);
			vis[s]=1;
			ans[s-1]=k<<1;
			while(!q.empty()){
				ll u=q.front();
				q.pop();
				go(u){
					ll v=e[i].to;
					if(ck[v]||vis[v]||blg[v]!=k) continue;
					vis[v]=1;
					ans[v-1]=ans[u-1]^1;
				}
			}
		}
	}
	pfr(j,tot,1){
		ll u=id[j];
		fr(i,0,7) pd[i]=0;
		go(u){
			ll v=e[i].to;
			if(ck[v]) continue;
			pd[ans[v-1]]=1;
		}
		fr(i,0,7) if(!pd[i]) ans[u-1]=i;
		ck[u]=0;
	}
	return ans;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 17ms
memory: 31584kb

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

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

result:

wrong answer the color of the vertex 9948 and 2453 is the same