QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#545525#8544. Colorful Graph 2WA_Synadrome#WA 3ms52392kbC++141.3kb2024-09-03 14:41:442024-09-03 14:41:44

Judging History

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

  • [2024-09-03 14:41:44]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:52392kb
  • [2024-09-03 14:41:44]
  • 提交

answer

#include <bits/stdc++.h>
// #pragma GCC optimize(3,"Ofast","inline")
using namespace std;
typedef long long ll;
typedef long double db;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<db, db> pdd;
typedef pair<ll, ll> pll;
void init();
#define Clear(a) memset(a, 0, sizeof(a))
#define pb(x) push_back(x)

#define INF 1e9 + 10
const int N = 2e6 + 10;
const int M = 3e4 + 10;
const ll mod = 1e9 + 7;

const bool IN_TEST = 1;

vector<int> from[N];
int dep[N];

void dfs(int u,int fa){
    for (int v:from[u]){
        if (v==fa || dep[v]) continue;
        dep[v] = dep[u]+1;
        dfs(v,u);
    }
}

void solve(){
    int n,m;
    cin>>n>>m;
    for (int i=0;i<=n;i++) from[i].clear(), dep[i]=0;
    for (int i=0;i<n;i++){
        int v=(i+1)%n;
        from[i].pb(v);
        from[v].pb(i);
    }
    for (int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        from[u].pb(v);
        from[v].pb(u);
    }
    dep[0] = 1;
    dfs(0,-1);
    for (int i=0;i<n;i++){
        if (dep[i]&1) cout<<"R";
        else cout<<"B";
    }
    cout<<endl;
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    init();
    int t = 1;
    if (IN_TEST)
        cin >> t;
    while (t--)
        solve();
    return 0;
}

void init()
{
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 52392kb

input:

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

output:

RBR
RBRB
RBRBRB

result:

wrong answer cycle detected (test case 3)