QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#440619#8544. Colorful Graph 2w4p3rWA 1ms3536kbC++20954b2024-06-13 21:19:082024-06-13 21:19:09

Judging History

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

  • [2024-06-13 21:19:09]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3536kb
  • [2024-06-13 21:19:08]
  • 提交

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 = 0; i < n; i ++)
    {
        if (ans[i] == 1) cout << 'R';
        if (ans[i] == 2) cout << 'B';
    }
    cout << '\n';

    for (int i = 0; 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: 1ms
memory: 3536kb

input:

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

output:

RBB

result:

wrong output format Unexpected end of file - token expected (test case 2)