QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#390820#8544. Colorful Graph 2Core_65536WA 1ms3596kbC++171.3kb2024-04-15 22:36:032024-04-15 22:36:03

Judging History

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

  • [2024-04-15 22:36:03]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3596kb
  • [2024-04-15 22:36:03]
  • 提交

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)