QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#390820 | #8544. Colorful Graph 2 | Core_65536 | WA | 1ms | 3596kb | C++17 | 1.3kb | 2024-04-15 22:36:03 | 2024-04-15 22:36:03 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
void solve()
{
int n,m; cin>>n>>m;
vector<vector<int>> v(n);
for(int i=0;i<n;i++)
v[i].push_back((i+1)%n), v[i].push_back((i-1+n)%n);
for(int i=0;i<m;i++)
{
int x,y; cin>>x>>y;
v[x].push_back(y);
v[y].push_back(x);
}
//Start BFS
vector<int> vis(n+5,0);
queue<pair<int,int>> q;//first is node,second is floor
q.push({0,1});
vis[0]=1;
//BFS
vector<pair<int,bool>> ans; ans.push_back({0,0});
while(!q.empty()){
pair<int,int> Qfro = q.front();
for(int i=0;i<v[Qfro.first].size();i++){
int ThisDes = v[Qfro.first][i];
if(!vis[ThisDes]){
vis[ThisDes]=1;
cout<<ThisDes<<'&'<<Qfro.second<<' ';
ans.push_back({ThisDes,Qfro.second%2});
q.push({ThisDes,Qfro.second+1});
}
}
q.pop();
}
cout<<endl;
sort(ans.begin(),ans.end());
for(auto i:ans){
if(i.second) cout<<'R';
else cout<<'B';
}
cout<<endl;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int T=1; cin>>T;
while(T--) solve();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3596kb
input:
3 3 0 4 1 1 3 6 3 0 2 2 4 4 0
output:
1&1 2&1 BRR 1&1 3&1 2&2 BRBR 1&1 5&1 2&1 4&1 3&2 BRRBRR
result:
wrong answer Token parameter [name=S] equals to "1&1", doesn't correspond to pattern "[BR]{1,200000}" (test case 1)