QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#544493#8544. Colorful Graph 2HTensor#WA 71ms3536kbC++171.3kb2024-09-02 17:21:172024-09-02 17:21:17

Judging History

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

  • [2024-09-02 17:21:17]
  • 评测
  • 测评结果:WA
  • 用时:71ms
  • 内存:3536kb
  • [2024-09-02 17:21:17]
  • 提交

answer

#include <bits/stdc++.h>
#define dd(x) cout << #x << "\n"
#define d(x) cout << #x  << ": " << x << "\n"
using namespace std;
#define int long long
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vii = vector<vector<int>>;
using a3 = array<int, 3>;
const int inf = 0x3f3f3f3f3f3f3f3fLL;

void solve() {
    int n, m; cin >> n >> m;
    set<int> s;
    vector<int> col(n);
    fill(col.begin(), col.end(), -1);
    for(int i = 1; i <= m; i++) {
        int u, v; cin >> u >> v;
        s.insert(u); s.insert(v);
    }
    
    s.insert(0); s.insert(1);
    int now = 0;
    for(auto it : s) {
        col[it] = now;
        now = !now;
    }

    int st = *s.begin();
    for(int i = st + 1; i < n; i++) {
        if(col[i] == -1) {
            col[i] = !col[i - 1];
        }
    }

    if(~col[0]) col[0] = !col[n];
    for(int i = 1; i < st; i++) {
        if(!col[i]) {
            col[i] = !col[i - 1];
        }
    }

    for(int i = 0; i < n; i++) {
        cout << (col[i] ? "R" : "B");
    }
    cout << "\n";
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int T; cin >> T;
    while(T--) solve();
    return 0;
}

/*
3
3 0

4 1
1 3

6 3
0 2
2 4
4 0
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3536kb

input:

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

output:

BRB
RRBB
RRBRRB

result:

ok ok (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 71ms
memory: 3500kb

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:

BRBRBRRBR
BRB
BRBRR
RRBRRB
BRBBRBBRR
BRB
BRBBRBB
BRBBRBR
RRBB
BRBRRB
BRBBRR
BRBRBBR
BRBBRBRR
BRB
BRBRBRRB
BRBBRBRR
BRB
RRBRBRBRRB
BRBBRBBR
RRBRBRBBRB
RRBRBRRBRB
RRBRBRRBRR
BRB
BRBRRBB
RRBBRB
BRBRRBRB
RRBB
BRBRBBR
RRBRBRRBRB
BRBRBBR
BRBRRBBR
BRBBRB
BRBRRB
BRB
BRB
BRBBRBBRB
BRBRRBB
BRBBR
RRBRBBRBBR
BR...

result:

wrong answer cycle detected (test case 22)