QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#638089#8544. Colorful Graph 2argtarg#WA 62ms3628kbC++20969b2024-10-13 14:53:142024-10-13 14:53:15

Judging History

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

  • [2024-10-13 14:53:15]
  • 评测
  • 测评结果:WA
  • 用时:62ms
  • 内存:3628kb
  • [2024-10-13 14:53:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pii pair<int, int>
void solve();

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int T = 1;
    cin >> T;
    while (T--)solve();
    return 0;
}
//const int mod = 998244353;

void solve()
{
    int n,m;
    cin>>n>>m;
    vector<vector<int>>g(n);
    int s=0;
    for(int i=1;i<=m;i++){
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
        s=x;
    }
    int ok=1;
    vector<int>ans(n),vis(n);
    for(int i=0;i<n;i++){
        int t=(i+s)%n;
        vis[t]=1;
        if(g[t].size()==0){
            ans[t]=ans[(t-1+n)%n]^1;
            continue;
        }
        for(int j:g[t]){
            if(vis[j])continue;
            ans[j]=ans[t]^1;
        }
    }
    for(int i=0;i<n;i++)cout<<(ans[i]==1 ? "B":"R");
    cout<<endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3612kb

input:

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

output:

BRB
RRBB
BRRBRB

result:

ok ok (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 62ms
memory: 3628kb

input:

100000
9 6
2 0
4 6
3 6
0 6
0 7
2 6
3 0
5 2
2 4
2 0
6 3
1 5
4 1
2 4
9 6
3 1
6 4
8 1
3 6
1 6
8 6
3 0
7 4
3 0
4 0
6 4
3 1
7 4
5 1
5 0
3 1
1 4
4 1
1 3
6 3
2 4
4 0
2 0
6 3
3 0
1 3
5 3
7 4
0 5
2 5
5 1
3 5
8 5
4 1
5 1
5 0
1 3
5 7
3 0
8 5
0 2
4 6
0 6
0 3
4 0
8 5
5 1
1 4
5 0
3 1
5 7
3 0
10 7
0 2
9 2
5 8
3 9
...

output:

BRRRRBBRB
BRB
BRRBB
BBRBBR
BBRRRBBRR
BRB
BBRRRBB
RRBBBBR
RRBB
RBRBBR
RRBBRR
RRRRBBR
BBRRRRBB
BRB
RBBBRBBR
BBRRRRBB
BRB
RBBBBBBRRR
BBRRRBBR
BBBBRRBBBR
BBBRRBBBRR
RBBBBRRRBB
BRB
RRBRRBB
BBRRRR
RBBRRRRR
RRBB
RBBRBBB
BBBRRBBRRR
BBBRBBR
RRRBBRRB
BBRRRR
BRRBRB
BRB
BRB
RRBBBRRRB
RRRBBRR
RRBBR
BBRRBBBRRR
BB...

result:

wrong answer cycle detected (test case 83)