QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#49170#1812. Interesting ColoringCrysflyWA 0ms16500kbC++112.5kb2022-09-19 16:10:082022-09-19 16:10:11

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-19 16:10:11]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:16500kb
  • [2022-09-19 16:10:08]
  • 提交

answer

// what is matter? never mind. 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
//#define int long long 
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 500005
#define inf 0x3f3f3f3f

int n,m;
struct edge{
	int to,nxt,w;
}e[maxn];
int tot=1,head[maxn];
vi out[maxn];
void adde(int u,int v){
	e[++tot]=(edge){v,head[u]};
	head[u]=tot;
}

int col[maxn];
int sz[maxn],fa[maxn],up[maxn],dep[maxn];
void dfs(int u)
{
	sz[u]=1;
	for(int i=head[u];i;i=e[i].nxt){
		int v=e[i].to;
		if((i^1)==up[u])continue;
		if(!dep[v]){
//			cout<<"dfs "<<u<<" "<<v<<" "<<(i/2)<<endl;
			dep[v]=dep[u]+1,fa[v]=u,up[v]=i;
			dfs(v),sz[u]+=sz[v];
		}
	}
}

int cnt;
int rnk[maxn],cnte[maxn];
bool in[maxn]; vi o;
void make(int u,int v){
	while(u!=v){
		++cnte[col[up[u]]];
		if(!in[col[up[u]]])in[col[up[u]]]=1,o.pb(col[up[u]]);
		u=fa[u]; 
	}
}
void clr(){
	for(int x:o)in[x]=cnte[x]=0;
	o.clear();
}
bool cmp(pii x,pii y){
	return sz[x.fi]>sz[y.fi];
}
void solve(int u)
{
	vector<pii>son;
	for(int i=head[u];i;i=e[i].nxt){
		int v=e[i].to;
		if((i^1)==up[u])continue;
		if(dep[v]<dep[u]){
			make(u,v);
			col[i]=col[i^1]=++cnt;
//			cout<<"col: "<<(i/2)<<' '<<cnt<<endl;
			out[i>>1]=o;
			for(int x=u;x!=v;x=fa[x]){
				int j=up[x];
				if(!out[j>>1].size()){
					out[j>>1].pb(cnt);
					--cnte[col[j]];
					for(int _:o)if(cnte[_])out[j>>1].pb(_);
					++cnte[col[j]];
				}
			}
			clr();
		}
		else if(up[v]==i)son.pb(mkp(v,i));
	}
	sort(son.begin(),son.end(),cmp);
	make(u,1);
	vi tmp; for(auto X:o)if(X!=col[up[u]])tmp.pb(X); o=tmp;
	while(o.size()<son.size())o.pb(++cnt);
//	cout<<"u: "<<u<<endl;
//	cout<<"son: "<<son.size()<<endl;
//	for(auto t:o)cout<<t<<" ";puts("");
	int p=0;
	for(auto t:son){
		int v=t.fi,i=t.se;
		col[i]=col[i^1]=o[p++];
	}
	clr();
	for(auto t:son)solve(t.fi);
}

signed main()
{
	n=read(),m=read();
	For(i,1,m){
		int u=read(),v=read();
		adde(u,v),adde(v,u);
	}
	dep[1]=1,dfs(1);
	solve(1);
	For(i,1,m)cout<<col[i<<1]<<" \n"[i==m];
	For(i,1,m){
		cout<<out[i].size()<<" ";
		for(auto t:out[i])cout<<t<<" \n"[t==out[i].back()];
	}
	return 0;
}
// e1e1e2 d7d7d8 f7f7f7

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 16500kb

input:

10 11
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
1 10
1 4

output:

11 10 3 2 4 5 6 7 8 9 1
1 10
1 11
2 11 10
2 9 8
2 9 8
2 9 8
2 9 8
2 9 8
1 9
1 8
2 9 8

result:

wrong answer wrong answer, a path about edge1 does not exist