QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#692425#8544. Colorful Graph 2sdmrlhWA 46ms27184kbC++141.1kb2024-10-31 14:29:292024-10-31 14:30:01

Judging History

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

  • [2024-10-31 14:30:01]
  • 评测
  • 测评结果:WA
  • 用时:46ms
  • 内存:27184kb
  • [2024-10-31 14:29:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define sf(x) scanf("%lld",&x)
#define sff(x,y) scanf("%lld%lld",&x,&y)
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pf(x) printf("%lld",x)
#define pii pair<int,int> 
#define f first 
#define s second
#define int long long



//
const int N = 1e6+10;
int h[N],ne[N],e[N],idx;
//
void add(int a,int b)
{
	ne[idx]=h[a],e[idx]=b,h[a]=idx++;
}

void bfs(string &now)
{
	queue<int>qu;
	now[0]='R';
	qu.push(1);
	
	while(qu.size())
	{
		int t =qu.front();
		qu.pop();
		
		for(int i=h[t];~i;i=ne[i])
		{
			int j=e[i];
			
			if(now[j-1]!='Z') continue;
			now[j-1]='R'+'B'-now[t-1];
			qu.push(j);
		}
	}
}
//


void solve()
{
	int m,n;
	cin>>m>>n;
	string res(m,'Z');
	for(int i=1;i<=4*m;i++) h[i]=-1;
	while(n--)
	{
		int a,b;
		cin>>a>>b;
		a++,b++;
		add(a,b);
		add(b,a);
	}
	
	for(int i=0;i<m;i++)
	{
		int x=i+1,y=(i+1)%m+1;
		add(x,y);
		add(y,x);
	}
	bfs(res);
	
	cout<<res<<endl;
}	
signed main()
{
	IOS;
	int _=1;
	cin>>_;
	while(_--)
		solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 7740kb

input:

3
3 0
4 1
1 3
6 3
0 2
2 4
4 0

output:

RBB
RBRB
RBBRBB

result:

ok ok (3 test cases)

Test #2:

score: 0
Accepted
time: 46ms
memory: 27184kb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BBRB
RBRRBB
RBRBBRB
RBRBB
RBRBBRBBRB
RBRRB
RBB
RBRBRBBRB
RBB
RBRRB
RBRBRRBRB
RBRBRB
RBRRBBRB
RBRRB
RBRRBBRB
RBRBB
RBRBRRRB
RBRRBRB
RBRBRRBRBB
RBRBBRRRB
RBRBRRBRB
RBRBRB
RBRBBRB
RBB
RBRBRRBRRB
RBRRBB
RBRBRRBRB
RBRRB
RBRBRBRBRB
RBBRB
RBB...

result:

wrong answer Token parameter [name=S] equals to "RBZZRBRRB", doesn't correspond to pattern "[BR]{1,200000}" (test case 60579)