QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#807920#8544. Colorful Graph 2ucup-team2179#WA 57ms3632kbC++231.1kb2024-12-10 14:41:282024-12-10 14:41:32

Judging History

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

  • [2024-12-10 14:41:32]
  • 评测
  • 测评结果:WA
  • 用时:57ms
  • 内存:3632kb
  • [2024-12-10 14:41:28]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define ll long long
using namespace std;
const int maxn = 2e5 + 10;
vector<pii> G[maxn];
char ans[maxn];
int col[maxn];
void dfs(int u, int f) {
    for (auto [w, v] : G[u]) {
        if (col[v] == -1) {
            col[v] = col[u] ^ 1;
            dfs(v, u);
        } 
    }
}
void solve() {
    int n, m; cin >> n >> m;
    for (int i = 0; i < n; i++) G[i].clear(), col[i] = -1;
    for (int i = 0; i < n; i++) {
        G[i].emplace_back(1, (i + 1) % n);
        G[(i + 1) % n].emplace_back(1, i);
    }
    while (m--) {
        int u, v; cin >> u >> v;
        G[u].emplace_back(0, v);
        G[v].emplace_back(0, u);
    }
    for (int i = 0; i < n; i++)
        sort(G[i].begin(), G[i].end());
    col[0] = 0;
    dfs(0, 0);
    for (int i = 0; i < n; i++)
        if (col[i] == 0) cout << 'B';
        else cout << 'R';
    cout << "\n";
}
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

BRB
BRRB
BBRRBR

result:

ok ok (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 57ms
memory: 3632kb

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:

BBRRBRBRB
BRB
BBRRB
BRRBBR
BRRBBRRRB
BRB
BBRRBBR
BBBRBRB
BRRB
BBRRBR
BBRRRB
BBRBRRB
BBBRBRRB
BRB
BBRBRRBR
BBBRBRRB
BRB
BBRRBBRBRB
BRRBBRRB
BRRBBRRBRB
BRRRRBBBBR
BBRBBBRRRB
BRB
BRRBBBR
BRRBRB
BBRRBRBR
BRRB
BBRRRBB
BRRRBRBRBB
BRRRBBB
BRRBBBRB
BRRBRB
BBRRBR
BRB
BRB
BRRBRRBRB
BBRBRRB
BBRRB
BRRBRBBBRR
BB...

result:

wrong answer cycle detected (test case 22)