QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#440616#8544. Colorful Graph 2w4p3rWA 0ms3540kbC++20956b2024-06-13 21:18:402024-06-13 21:18:40

Judging History

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

  • [2024-06-13 21:18:40]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3540kb
  • [2024-06-13 21:18:40]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
#define N 200010
int n, m;
vector<int>e[N];
int ans[N];
void sol()
{
    cin >> n >> m;
    for (int i = 1; i <= m; i ++)
    {
        int u, v;
        cin >> u >> v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    for (int i = 0; i < n; i ++)
    {
        e[i].push_back((i + 1) % n);
        e[(i + 1) % n].push_back(i);
    }

    queue<int>q; ans[0] = 1; q.push(0);

    while(!q.empty())
    {
        int u = q.front(); q.pop();
        for (int v : e[u])if(ans[v] == 0)
        {
            ans[v] = 3 - ans[u]; q.push(v);
        }
    }

    for (int i = 1; i <= n; i ++)
    {
        if (ans[i] == 1) cout << 'R';
        if (ans[i] == 2) cout << 'B';
    }
    cout << '\n';

    for (int i = 1; i <= n; i ++)e[i].clear(), ans[i] = 0;
}
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
    sol();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

BB

result:

wrong answer the length doesn't equal n (test case 1)