QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#310735#8128. Alternating PathsKevin5307Compile Error//C++232.2kb2024-01-21 17:19:412024-01-21 17:19:41

Judging History

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

  • [2024-01-21 17:19:41]
  • 评测
  • [2024-01-21 17:19:41]
  • 提交

answer

//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
int u[303],v[303];
int n,m;
int c[303];
mt19937 rnd(114514);
vector<pii> G[105];
bool vis[105];
void dfs(int u,int d=0)
{
	vis[u]=1;
	for(auto pr:G[u])
		if(!vis[pr.first])
		{
			c[pr.second]=d;
			dfs(pr.first,u,d^1);
		}
}
void color()
{
	memset(vis,0,sizeof(vis));
	memset(c,-1,sizeof(c));
	dfs(rnd()%n+1,0);
	for(int i=1;i<=m;i++)
		if(c[i]==-1)
			c[i]=rnd()%2;
}
bitset<256> E[256];
bool check()
{
	for(int i=1;i<=n+n;i++)
		E[i]=0;
	for(int i=1;i<=m;i++)
		E[c[i]*n+u[i]][(c[i]^1)*n+v[i]]=E[c[i]*n+v[i]][(c[i]^1)*n+u[i]]=1;
	for(int i=1;i<=n;i++)
	{
		bitset<256> cur;
		queue<int> q;
		q.push(i);
		q.push(n+i);
		cur[i]=cur[n+i]=1;
		while(!q.empty())
		{
			int x=q.front();
			q.pop();
			bitset<256> bs=E[x]^(E[x]&cur);
			cur|=bs;
			int p=bs._Find_first();
			while(p<=n+n)
			{
				q.push(p);
				p=bs._Find_next(p);
			}
		}
		for(int j=1;j<=n;j++)
			if(!cur[j]&&!cur[j+n])
				return false;
	}
	return true;
}
void solve()
{
	for(int i=1;i<=n;i++)
		G[i].clear();
	for(int i=1;i<=m;i++)
	{
		G[u[i]].pb(v[i],i);
		G[v[i]].pb(u[i],i);
	}
	int threshold=30000;
	while(threshold--)
	{
		color();
		if(check())
		{
			for(int i=1;i<=m;i++)
				putchar(c[i]?'R':'B');
			putchar(10);
			return ;
		}
	}
	puts("IMPOSSIBLE");
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--)
	{
		cin>>n>>m;
		for(int i=1;i<=m;i++)
			cin>>u[i]>>v[i];
		solve();
	}
	return 0;
}

详细

answer.code: In function ‘void dfs(int, int)’:
answer.code:35:28: error: too many arguments to function ‘void dfs(int, int)’
   35 |                         dfs(pr.first,u,d^1);
      |                         ~~~^~~~~~~~~~~~~~~~
answer.code:28:6: note: declared here
   28 | void dfs(int u,int d=0)
      |      ^~~