QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#721985#9484. Colored Complete GraphOneWan#AC ✓1537ms15856kbC++233.1kb2024-11-07 17:22:372024-11-07 17:22:37

Judging History

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

  • [2024-11-07 17:22:37]
  • 评测
  • 测评结果:AC
  • 用时:1537ms
  • 内存:15856kb
  • [2024-11-07 17:22:37]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int f[2][50005];
int find(int col, int x) {
    return f[col][x] == x ? x : f[col][x] = find(col, f[col][x]);
}
map<array<int, 2>, int> qry;
vector<int> adj[50005];
int qry_cnt, N;
int query(int u, int v) {
    if (u > v) swap(u, v);
    if (qry.count({u, v})) return qry[{u, v}];
    adj[u].push_back(v);
    adj[v].push_back(u);
    qry_cnt++;
    assert(qry_cnt <= 2 * N);
    cout << "? " << u << " " << v << endl;
    char col;
    cin >> col;
    int k = 0;
    if (col == 'B') {
        k = 1;
    }
    return qry[{u, v}] = k;
}
bool vis[50005];
void dfs(int u, int p, int col) {
    if (vis[u]) return;
    vis[u] = true;
    for (auto &to : adj[u]) {
        if (to == p) continue;
        if (query(u, to) != col) continue;
        cout << u << " " << to << "\n";
        dfs(to, u, col);
    }
}
vector<int> mp[50005];
signed main() {
    int n;
    cin >> n;
    N = n;
    for (int i = 1 ; i <= n ; i++) {
        f[0][i] = f[1][i] = i;
    }
    unordered_set<int> st0;
    for (int i = 2 ; i <= n ; i++) {
        st0.insert(i);
    }
    queue<int> que;
    que.push(1);
    while (!que.empty()) {
        int x = que.front();
        que.pop();
        vector<int> s;
        for (auto &y : st0) {
            int tx = find(1, x), ty = find(1, y);
            if (tx == ty) continue;
            int k = query(x, y);
            if (k == 0) {
                int ttx = find(0, x), tty = find(0, y);
                f[0][ttx] = tty;
                s.push_back(y);
            } else {
                f[1][tx] = ty;
            }
        }
        for (auto &y : s) {
            st0.erase(y);
            que.push(y);
        }
    }
    if (st0.empty()) {
        // 红色出答案
        cout << "!" << endl;
        dfs(1, 0, 0);
    } else {
        int now = -1;
        for (int i = 1 ; i <= n ; i++) {
            int x = find(1, i);
            mp[x].push_back(i);
            now = x;
        }
        for (int i = 1 ; i <= n ; i++) {
            st0.insert(i);
        }
        for (auto &x : mp[now]) {
            que.push(x);
            st0.erase(x);
        }
        while (!que.empty()) {
            int x = que.front();
            que.pop();
            unordered_set<int> s;
            for (auto &y : st0) {
                int tx = find(0, x), ty = find(0, y);
                if (tx == ty) continue;
                if (s.count(y)) continue;
                int k = query(x, y);
                if (k == 0) {
                    f[0][tx] = ty;
                } else {
                    int ttx = find(1, x), tty = find(1, y);
                    for (auto &z : mp[tty]) {
                        s.insert(z);
                    }
                    f[1][ttx] = tty;
                }
            }
            for (auto &y : s) {
                st0.erase(y);
                que.push(y);
            }
        }
        cout << "!" << endl;
        dfs(1, 0, 1);
    }
    return 0;
}

詳細信息

Test #1:

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

input:

3
R
B
B

output:

? 1 3
? 1 2
? 2 3
!
1 2
2 3

result:

ok AC

Test #2:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

983
B
R
R
B
B
B
B
B
R
B
R
R
R
R
R
R
R
B
B
R
R
B
R
B
R
R
B
B
R
B
R
R
R
R
B
R
B
B
B
R
R
R
B
B
R
R
B
R
B
R
B
B
B
R
B
R
R
B
R
B
B
R
R
R
B
B
B
B
R
B
R
R
B
R
B
B
R
B
R
B
R
B
R
R
R
B
B
B
R
R
B
B
B
R
R
B
R
B
B
B
R
B
B
R
R
B
B
R
R
R
R
B
R
R
B
B
B
R
B
B
B
B
R
B
R
R
B
R
R
R
B
R
R
B
R
R
B
R
R
B
R
B
R
B
B
R
B
R
...

output:

? 1 983
? 1 982
? 1 981
? 1 980
? 1 979
? 1 978
? 1 977
? 1 976
? 1 975
? 1 974
? 1 973
? 1 972
? 1 971
? 1 970
? 1 969
? 1 968
? 1 967
? 1 966
? 1 965
? 1 964
? 1 963
? 1 962
? 1 961
? 1 960
? 1 959
? 1 958
? 1 957
? 1 956
? 1 955
? 1 954
? 1 953
? 1 952
? 1 951
? 1 950
? 1 949
? 1 948
? 1 947
? 1 ...

result:

ok AC

Test #3:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

75
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R

output:

? 1 75
? 1 74
? 1 73
? 1 72
? 1 71
? 1 70
? 1 69
? 1 68
? 1 67
? 1 66
? 1 65
? 1 64
? 1 63
? 1 62
? 1 61
? 1 30
? 1 29
? 1 28
? 1 27
? 1 26
? 1 25
? 1 24
? 1 23
? 1 22
? 1 21
? 1 20
? 1 19
? 1 18
? 1 17
? 1 16
? 1 15
? 1 2
? 1 3
? 1 4
? 1 5
? 1 6
? 1 7
? 1 8
? 1 9
? 1 10
? 1 11
? 1 12
? 1 13
? 1 14
...

result:

ok AC

Test #4:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

430
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 430
? 1 429
? 1 428
? 1 427
? 1 426
? 1 425
? 1 424
? 1 423
? 1 422
? 1 421
? 1 420
? 1 419
? 1 418
? 1 417
? 1 416
? 1 415
? 1 414
? 1 413
? 1 412
? 1 411
? 1 410
? 1 409
? 1 408
? 1 407
? 1 406
? 1 405
? 1 404
? 1 403
? 1 402
? 1 401
? 1 400
? 1 399
? 1 398
? 1 397
? 1 396
? 1 395
? 1 394
? 1 ...

result:

ok AC

Test #5:

score: 0
Accepted
time: 0ms
memory: 5912kb

input:

238
B
R
R
B
B
B
B
B
R
B
R
R
R
R
R
R
R
B
B
R
R
B
R
B
R
R
B
B
R
B
R
R
R
R
B
R
B
B
B
R
R
R
B
B
R
R
B
R
B
R
B
B
B
R
B
R
R
B
R
B
B
R
R
R
B
B
B
B
R
B
R
R
B
R
B
B
R
B
R
B
R
B
R
R
R
B
B
B
R
R
B
B
B
R
R
B
R
B
B
B
R
B
B
R
R
B
B
R
R
R
R
B
R
R
B
B
B
R
B
B
B
B
R
B
R
R
B
R
R
R
B
R
R
B
R
R
B
R
R
B
R
B
R
B
B
R
B
R
...

output:

? 1 238
? 1 237
? 1 236
? 1 235
? 1 234
? 1 233
? 1 232
? 1 231
? 1 230
? 1 229
? 1 228
? 1 227
? 1 226
? 1 225
? 1 224
? 1 223
? 1 222
? 1 221
? 1 220
? 1 219
? 1 218
? 1 217
? 1 216
? 1 215
? 1 214
? 1 213
? 1 212
? 1 211
? 1 210
? 1 209
? 1 208
? 1 207
? 1 206
? 1 205
? 1 204
? 1 203
? 1 202
? 1 ...

result:

ok AC

Test #6:

score: 0
Accepted
time: 0ms
memory: 5888kb

input:

42
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B

output:

? 1 42
? 1 41
? 1 40
? 1 39
? 1 38
? 1 37
? 1 36
? 1 35
? 1 34
? 1 33
? 1 32
? 1 31
? 1 14
? 1 13
? 1 12
? 1 11
? 1 10
? 1 9
? 1 8
? 1 7
? 1 6
? 1 5
? 1 4
? 1 3
? 1 2
? 1 15
? 1 16
? 1 17
? 1 18
? 1 19
? 1 20
? 1 21
? 1 22
? 1 23
? 1 24
? 1 25
? 1 26
? 1 27
? 1 28
? 1 29
? 1 30
? 30 42
? 30 41
? 30 ...

result:

ok AC

Test #7:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

759
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 759
? 1 758
? 1 757
? 1 756
? 1 755
? 1 754
? 1 753
? 1 752
? 1 751
? 1 750
? 1 749
? 1 748
? 1 747
? 1 746
? 1 745
? 1 744
? 1 743
? 1 742
? 1 741
? 1 740
? 1 739
? 1 738
? 1 737
? 1 736
? 1 735
? 1 734
? 1 733
? 1 732
? 1 731
? 1 730
? 1 729
? 1 728
? 1 727
? 1 726
? 1 725
? 1 724
? 1 723
? 1 ...

result:

ok AC

Test #8:

score: 0
Accepted
time: 0ms
memory: 3704kb

input:

389
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
B
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 389
? 1 388
? 1 387
? 1 386
? 1 385
? 1 384
? 1 383
? 1 382
? 1 381
? 1 380
? 1 379
? 1 378
? 1 377
? 1 376
? 1 375
? 1 374
? 1 373
? 1 372
? 1 371
? 1 370
? 1 369
? 1 368
? 1 367
? 1 366
? 1 365
? 1 364
? 1 363
? 1 362
? 1 361
? 1 360
? 1 359
? 1 358
? 1 357
? 1 356
? 1 355
? 1 354
? 1 353
? 1 ...

result:

ok AC

Test #9:

score: 0
Accepted
time: 1ms
memory: 3852kb

input:

47
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
B
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B

output:

? 1 47
? 1 46
? 1 45
? 1 44
? 1 43
? 1 42
? 1 41
? 1 40
? 1 39
? 1 38
? 1 37
? 1 36
? 1 35
? 1 34
? 1 33
? 1 32
? 1 31
? 1 14
? 1 13
? 1 12
? 1 11
? 1 10
? 1 9
? 1 8
? 1 7
? 1 6
? 1 5
? 1 4
? 1 3
? 1 2
? 1 15
? 1 16
? 1 17
? 1 18
? 1 19
? 1 20
? 1 21
? 1 22
? 1 23
? 1 24
? 1 25
? 1 26
? 1 27
? 1 28
...

result:

ok AC

Test #10:

score: 0
Accepted
time: 28ms
memory: 7456kb

input:

14657
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 14657
? 1 14656
? 1 14655
? 1 14654
? 1 14653
? 1 14652
? 1 14651
? 1 14650
? 1 14649
? 1 14648
? 1 14647
? 1 14646
? 1 14645
? 1 14644
? 1 14643
? 1 14642
? 1 14641
? 1 14640
? 1 14639
? 1 14638
? 1 14637
? 1 14636
? 1 14635
? 1 14634
? 1 14633
? 1 14632
? 1 14631
? 1 14630
? 1 14629
? 1 14628
...

result:

ok AC

Test #11:

score: 0
Accepted
time: 38ms
memory: 6200kb

input:

15755
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 15755
? 1 15754
? 1 15753
? 1 15752
? 1 15751
? 1 15750
? 1 15749
? 1 15748
? 1 15747
? 1 15746
? 1 15745
? 1 15744
? 1 15743
? 1 15742
? 1 15741
? 1 15740
? 1 15739
? 1 15738
? 1 15737
? 1 15736
? 1 15735
? 1 15734
? 1 15733
? 1 15732
? 1 15731
? 1 15730
? 1 15729
? 1 15728
? 1 15727
? 1 15726
...

result:

ok AC

Test #12:

score: 0
Accepted
time: 145ms
memory: 8432kb

input:

14236
B
R
R
B
B
B
B
B
R
B
R
R
R
R
R
R
R
B
B
R
R
B
R
B
R
R
B
B
R
B
R
R
R
R
B
R
B
B
B
R
R
R
B
B
R
R
B
R
B
R
B
B
B
R
B
R
R
B
R
B
B
R
R
R
B
B
B
B
R
B
R
R
B
R
B
B
R
B
R
B
R
B
R
R
R
B
B
B
R
R
B
B
B
R
R
B
R
B
B
B
R
B
B
R
R
B
B
R
R
R
R
B
R
R
B
B
B
R
B
B
B
B
R
B
R
R
B
R
R
R
B
R
R
B
R
R
B
R
R
B
R
B
R
B
B
R
B
...

output:

? 1 14236
? 1 14235
? 1 14234
? 1 14233
? 1 14232
? 1 14231
? 1 14230
? 1 14229
? 1 14228
? 1 14227
? 1 14226
? 1 14225
? 1 14224
? 1 14223
? 1 14222
? 1 14221
? 1 14220
? 1 14219
? 1 14218
? 1 14217
? 1 14216
? 1 14215
? 1 14214
? 1 14213
? 1 14212
? 1 14211
? 1 14210
? 1 14209
? 1 14208
? 1 14207
...

result:

ok AC

Test #13:

score: 0
Accepted
time: 81ms
memory: 9600kb

input:

19615
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 19615
? 1 19614
? 1 19613
? 1 19612
? 1 19611
? 1 19610
? 1 19609
? 1 19608
? 1 19607
? 1 19606
? 1 19605
? 1 19604
? 1 19603
? 1 19602
? 1 19601
? 1 19600
? 1 19599
? 1 19598
? 1 19597
? 1 19596
? 1 19595
? 1 19594
? 1 19593
? 1 19592
? 1 19591
? 1 19590
? 1 19589
? 1 19588
? 1 19587
? 1 19586
...

result:

ok AC

Test #14:

score: 0
Accepted
time: 46ms
memory: 8712kb

input:

30668
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 30668
? 1 30667
? 1 30666
? 1 30665
? 1 30664
? 1 30663
? 1 30662
? 1 30661
? 1 30660
? 1 30659
? 1 30658
? 1 30657
? 1 30656
? 1 30655
? 1 30654
? 1 30653
? 1 30652
? 1 30651
? 1 30650
? 1 30649
? 1 30648
? 1 30647
? 1 30646
? 1 30645
? 1 30644
? 1 30643
? 1 30642
? 1 30641
? 1 30640
? 1 30639
...

result:

ok AC

Test #15:

score: 0
Accepted
time: 185ms
memory: 12500kb

input:

39166
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 39166
? 1 39165
? 1 39164
? 1 39163
? 1 39162
? 1 39161
? 1 39160
? 1 39159
? 1 39158
? 1 39157
? 1 39156
? 1 39155
? 1 39154
? 1 39153
? 1 39152
? 1 39151
? 1 39150
? 1 39149
? 1 39148
? 1 39147
? 1 39146
? 1 39145
? 1 39144
? 1 39143
? 1 39142
? 1 39141
? 1 39140
? 1 39139
? 1 39138
? 1 39137
...

result:

ok AC

Test #16:

score: 0
Accepted
time: 76ms
memory: 9376kb

input:

35168
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 35168
? 1 35167
? 1 35166
? 1 35165
? 1 35164
? 1 35163
? 1 35162
? 1 35161
? 1 35160
? 1 35159
? 1 35158
? 1 35157
? 1 35156
? 1 35155
? 1 35154
? 1 35153
? 1 35152
? 1 35151
? 1 35150
? 1 35149
? 1 35148
? 1 35147
? 1 35146
? 1 35145
? 1 35144
? 1 35143
? 1 35142
? 1 35141
? 1 35140
? 1 35139
...

result:

ok AC

Test #17:

score: 0
Accepted
time: 104ms
memory: 12524kb

input:

45420
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 45420
? 1 45419
? 1 45418
? 1 45417
? 1 45416
? 1 45415
? 1 45414
? 1 45413
? 1 45412
? 1 45411
? 1 45410
? 1 45409
? 1 45408
? 1 45407
? 1 45406
? 1 45405
? 1 45404
? 1 45403
? 1 45402
? 1 45401
? 1 45400
? 1 45399
? 1 45398
? 1 45397
? 1 45396
? 1 45395
? 1 45394
? 1 45393
? 1 45392
? 1 45391
...

result:

ok AC

Test #18:

score: 0
Accepted
time: 93ms
memory: 11492kb

input:

45526
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 45526
? 1 45525
? 1 45524
? 1 45523
? 1 45522
? 1 45521
? 1 45520
? 1 45519
? 1 45518
? 1 45517
? 1 45516
? 1 45515
? 1 45514
? 1 45513
? 1 45512
? 1 45511
? 1 45510
? 1 45509
? 1 45508
? 1 45507
? 1 45506
? 1 45505
? 1 45504
? 1 45503
? 1 45502
? 1 45501
? 1 45500
? 1 45499
? 1 45498
? 1 45497
...

result:

ok AC

Test #19:

score: 0
Accepted
time: 104ms
memory: 11980kb

input:

48225
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 48225
? 1 48224
? 1 48223
? 1 48222
? 1 48221
? 1 48220
? 1 48219
? 1 48218
? 1 48217
? 1 48216
? 1 48215
? 1 48214
? 1 48213
? 1 48212
? 1 48211
? 1 48210
? 1 48209
? 1 48208
? 1 48207
? 1 48206
? 1 48205
? 1 48204
? 1 48203
? 1 48202
? 1 48201
? 1 48200
? 1 48199
? 1 48198
? 1 48197
? 1 48196
...

result:

ok AC

Test #20:

score: 0
Accepted
time: 91ms
memory: 10200kb

input:

40451
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 40451
? 1 40450
? 1 40449
? 1 40448
? 1 40447
? 1 40446
? 1 40445
? 1 40444
? 1 40443
? 1 40442
? 1 40441
? 1 40440
? 1 40439
? 1 40438
? 1 40437
? 1 40436
? 1 40435
? 1 40434
? 1 40433
? 1 40432
? 1 40431
? 1 40430
? 1 40429
? 1 40428
? 1 40427
? 1 40426
? 1 40425
? 1 40424
? 1 40423
? 1 40422
...

result:

ok AC

Test #21:

score: 0
Accepted
time: 97ms
memory: 11736kb

input:

47265
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 47265
? 1 47264
? 1 47263
? 1 47262
? 1 47261
? 1 47260
? 1 47259
? 1 47258
? 1 47257
? 1 47256
? 1 47255
? 1 47254
? 1 47253
? 1 47252
? 1 47251
? 1 47250
? 1 47249
? 1 47248
? 1 47247
? 1 47246
? 1 47245
? 1 47244
? 1 47243
? 1 47242
? 1 47241
? 1 47240
? 1 47239
? 1 47238
? 1 47237
? 1 47236
...

result:

ok AC

Test #22:

score: 0
Accepted
time: 90ms
memory: 11236kb

input:

40881
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 40881
? 1 40880
? 1 40879
? 1 40878
? 1 40877
? 1 40876
? 1 40875
? 1 40874
? 1 40873
? 1 40872
? 1 40871
? 1 40870
? 1 40869
? 1 40868
? 1 40867
? 1 40866
? 1 40865
? 1 40864
? 1 40863
? 1 40862
? 1 40861
? 1 40860
? 1 40859
? 1 40858
? 1 40857
? 1 40856
? 1 40855
? 1 40854
? 1 40853
? 1 40852
...

result:

ok AC

Test #23:

score: 0
Accepted
time: 1136ms
memory: 13608kb

input:

44327
B
R
R
B
B
B
B
B
R
B
R
R
R
R
R
R
R
B
B
R
R
B
R
B
R
R
B
B
R
B
R
R
R
R
B
R
B
B
B
R
R
R
B
B
R
R
B
R
B
R
B
B
B
R
B
R
R
B
R
B
B
R
R
R
B
B
B
B
R
B
R
R
B
R
B
B
R
B
R
B
R
B
R
R
R
B
B
B
R
R
B
B
B
R
R
B
R
B
B
B
R
B
B
R
R
B
B
R
R
R
R
B
R
R
B
B
B
R
B
B
B
B
R
B
R
R
B
R
R
R
B
R
R
B
R
R
B
R
R
B
R
B
R
B
B
R
B
...

output:

? 1 44327
? 1 44326
? 1 44325
? 1 44324
? 1 44323
? 1 44322
? 1 44321
? 1 44320
? 1 44319
? 1 44318
? 1 44317
? 1 44316
? 1 44315
? 1 44314
? 1 44313
? 1 44312
? 1 44311
? 1 44310
? 1 44309
? 1 44308
? 1 44307
? 1 44306
? 1 44305
? 1 44304
? 1 44303
? 1 44302
? 1 44301
? 1 44300
? 1 44299
? 1 44298
...

result:

ok AC

Test #24:

score: 0
Accepted
time: 92ms
memory: 12032kb

input:

48093
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 48093
? 1 48092
? 1 48091
? 1 48090
? 1 48089
? 1 48088
? 1 48087
? 1 48086
? 1 48085
? 1 48084
? 1 48083
? 1 48082
? 1 48081
? 1 48080
? 1 48079
? 1 48078
? 1 48077
? 1 48076
? 1 48075
? 1 48074
? 1 48073
? 1 48072
? 1 48071
? 1 48070
? 1 48069
? 1 48068
? 1 48067
? 1 48066
? 1 48065
? 1 48064
...

result:

ok AC

Test #25:

score: 0
Accepted
time: 113ms
memory: 12912kb

input:

49999
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 49999
? 1 49998
? 1 49997
? 1 49996
? 1 49995
? 1 49994
? 1 49993
? 1 49992
? 1 49991
? 1 49990
? 1 49989
? 1 49988
? 1 49987
? 1 49986
? 1 49985
? 1 49984
? 1 49983
? 1 49982
? 1 49981
? 1 49980
? 1 49979
? 1 49978
? 1 49977
? 1 49976
? 1 49975
? 1 49974
? 1 49973
? 1 49972
? 1 49971
? 1 49970
...

result:

ok AC

Test #26:

score: 0
Accepted
time: 213ms
memory: 15856kb

input:

50000
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 50000
? 1 49999
? 1 49998
? 1 49997
? 1 49996
? 1 49995
? 1 49994
? 1 49993
? 1 49992
? 1 49991
? 1 49990
? 1 49989
? 1 49988
? 1 49987
? 1 49986
? 1 49985
? 1 49984
? 1 49983
? 1 49982
? 1 49981
? 1 49980
? 1 49979
? 1 49978
? 1 49977
? 1 49976
? 1 49975
? 1 49974
? 1 49973
? 1 49972
? 1 49971
...

result:

ok AC

Test #27:

score: 0
Accepted
time: 221ms
memory: 15780kb

input:

50000
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 50000
? 1 49999
? 1 49998
? 1 49997
? 1 49996
? 1 49995
? 1 49994
? 1 49993
? 1 49992
? 1 49991
? 1 49990
? 1 49989
? 1 49988
? 1 49987
? 1 49986
? 1 49985
? 1 49984
? 1 49983
? 1 49982
? 1 49981
? 1 49980
? 1 49979
? 1 49978
? 1 49977
? 1 49976
? 1 49975
? 1 49974
? 1 49973
? 1 49972
? 1 49971
...

result:

ok AC

Test #28:

score: 0
Accepted
time: 1537ms
memory: 14736kb

input:

49999
B
R
R
B
B
B
B
B
R
B
R
R
R
R
R
R
R
B
B
R
R
B
R
B
R
R
B
B
R
B
R
R
R
R
B
R
B
B
B
R
R
R
B
B
R
R
B
R
B
R
B
B
B
R
B
R
R
B
R
B
B
R
R
R
B
B
B
B
R
B
R
R
B
R
B
B
R
B
R
B
R
B
R
R
R
B
B
B
R
R
B
B
B
R
R
B
R
B
B
B
R
B
B
R
R
B
B
R
R
R
R
B
R
R
B
B
B
R
B
B
B
B
R
B
R
R
B
R
R
R
B
R
R
B
R
R
B
R
R
B
R
B
R
B
B
R
B
...

output:

? 1 49999
? 1 49998
? 1 49997
? 1 49996
? 1 49995
? 1 49994
? 1 49993
? 1 49992
? 1 49991
? 1 49990
? 1 49989
? 1 49988
? 1 49987
? 1 49986
? 1 49985
? 1 49984
? 1 49983
? 1 49982
? 1 49981
? 1 49980
? 1 49979
? 1 49978
? 1 49977
? 1 49976
? 1 49975
? 1 49974
? 1 49973
? 1 49972
? 1 49971
? 1 49970
...

result:

ok AC

Test #29:

score: 0
Accepted
time: 213ms
memory: 15368kb

input:

50000
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 50000
? 1 49999
? 1 49998
? 1 49997
? 1 49996
? 1 49995
? 1 49994
? 1 49993
? 1 49992
? 1 49991
? 1 49990
? 1 49989
? 1 49988
? 1 49987
? 1 49986
? 1 49985
? 1 49984
? 1 49983
? 1 49982
? 1 49981
? 1 49980
? 1 49979
? 1 49978
? 1 49977
? 1 49976
? 1 49975
? 1 49974
? 1 49973
? 1 49972
? 1 49971
...

result:

ok AC

Test #30:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

4
B
R
R
B
B

output:

? 1 4
? 1 3
? 1 2
? 3 4
? 2 4
!
1 4
4 3
4 2

result:

ok AC

Test #31:

score: 0
Accepted
time: 1ms
memory: 3844kb

input:

5
B
R
R
B
B
B

output:

? 1 5
? 1 4
? 1 3
? 1 2
? 4 5
? 3 5
!
1 5
5 4
5 3
1 2

result:

ok AC

Test #32:

score: 0
Accepted
time: 1ms
memory: 3620kb

input:

6
B
R
R
R
R
B
B
B
B

output:

? 1 6
? 1 5
? 1 4
? 1 3
? 1 2
? 5 6
? 4 6
? 3 6
? 2 6
!
1 6
6 5
6 4
6 3
6 2

result:

ok AC

Test #33:

score: 0
Accepted
time: 1471ms
memory: 14764kb

input:

50000
B
R
R
B
B
B
B
B
R
B
R
R
R
R
R
R
R
B
B
R
R
B
R
B
R
R
B
B
R
B
R
R
R
R
B
R
B
B
B
R
R
R
B
B
R
R
B
R
B
R
B
B
B
R
B
R
R
B
R
B
B
R
R
R
B
B
B
B
R
B
R
R
B
R
B
B
R
B
R
B
R
B
R
R
R
B
B
B
R
R
B
B
B
R
R
B
R
B
B
B
R
B
B
R
R
B
B
R
R
R
R
B
R
R
B
B
B
R
B
B
B
B
R
B
R
R
B
R
R
R
B
R
R
B
R
R
B
R
R
B
R
B
R
B
B
R
B
...

output:

? 1 50000
? 1 49999
? 1 49998
? 1 49997
? 1 49996
? 1 49995
? 1 49994
? 1 49993
? 1 49992
? 1 49991
? 1 49990
? 1 49989
? 1 49988
? 1 49987
? 1 49986
? 1 49985
? 1 49984
? 1 49983
? 1 49982
? 1 49981
? 1 49980
? 1 49979
? 1 49978
? 1 49977
? 1 49976
? 1 49975
? 1 49974
? 1 49973
? 1 49972
? 1 49971
...

result:

ok AC

Test #34:

score: 0
Accepted
time: 187ms
memory: 15276kb

input:

50000
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 50000
? 1 49999
? 1 49998
? 1 49997
? 1 49996
? 1 49995
? 1 49994
? 1 49993
? 1 49992
? 1 49991
? 1 49990
? 1 49989
? 1 49988
? 1 49987
? 1 49986
? 1 49985
? 1 49984
? 1 49983
? 1 49982
? 1 49981
? 1 49980
? 1 49979
? 1 49978
? 1 49977
? 1 49976
? 1 49975
? 1 49974
? 1 49973
? 1 49972
? 1 49971
...

result:

ok AC

Test #35:

score: 0
Accepted
time: 134ms
memory: 12108kb

input:

50000
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 50000
? 1 49999
? 1 49998
? 1 49997
? 1 49996
? 1 49995
? 1 49994
? 1 49993
? 1 49992
? 1 49991
? 1 49990
? 1 49989
? 1 49988
? 1 49987
? 1 49986
? 1 49985
? 1 49984
? 1 49983
? 1 49982
? 1 49981
? 1 49980
? 1 49979
? 1 49978
? 1 49977
? 1 49976
? 1 49975
? 1 49974
? 1 49973
? 1 49972
? 1 49971
...

result:

ok AC

Test #36:

score: 0
Accepted
time: 75ms
memory: 12124kb

input:

50000
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
...

output:

? 1 50000
? 1 49999
? 1 49998
? 1 49997
? 1 49996
? 1 49995
? 1 49994
? 1 49993
? 1 49992
? 1 49991
? 1 49990
? 1 49989
? 1 49988
? 1 49987
? 1 49986
? 1 49985
? 1 49984
? 1 49983
? 1 49982
? 1 49981
? 1 49980
? 1 49979
? 1 49978
? 1 49977
? 1 49976
? 1 49975
? 1 49974
? 1 49973
? 1 49972
? 1 49971
...

result:

ok AC

Extra Test:

score: 0
Extra Test Passed