QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#223402#2923. Code GuessingrlongAC ✓0ms3740kbC++171006b2023-10-22 02:29:362023-10-22 02:29:37

Judging History

This is the latest submission verdict.

  • [2023-10-22 02:29:37]
  • Judged
  • Verdict: AC
  • Time: 0ms
  • Memory: 3740kb
  • [2023-10-22 02:29:36]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

int main() {
    int p, q;
    cin >> p >> q;
    char c[5];
    int pos1 = 0;
    int pos2 = 0;
    int bos1 = 0;
    int bos2 = 0;
    for(int i=1;i<=4;i++) {
        cin >> c[i];
        if(c[i] == 'A' && pos1 == 0) pos1 = i;
        if(c[i] == 'A' && pos1 != 0) pos2 = i;
        if(c[i] == 'B' && bos1 == 0) bos1 = i;
        if(c[i] == 'B' && bos1 != 0) bos2 = i;
    }
    int left = pos1 - 1;
    int mid = pos2 - pos1 - 1;
    int right = 4 - pos2;
    
    int nleft = p - 1;
    int nmid = q - p - 1;
    int nright = 9 - q;
    
    if(nleft > left && left > 0
        || nmid > mid && mid > 0
        || nright > right && right > 0) cout << "-1" << endl;
    else {
        if(bos1 < pos2) cout << p + (bos1 - pos1) << " ";
        else cout << q + (bos1 - pos2) << " ";
        
        if(bos2 < pos2) cout << p + (bos2 - pos1) << endl;
        else cout << q + (bos2 - pos2) << endl;

    }
    
    
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 4
BBAA

output:

1 2

result:

ok single line: '1 2'

Test #2:

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

input:

3 7
BBAA

output:

1 2

result:

ok single line: '1 2'

Test #3:

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

input:

3 9
BBAA

output:

1 2

result:

ok single line: '1 2'

Test #4:

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

input:

5 6
BBAA

output:

-1

result:

ok single line: '-1'

Test #5:

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

input:

6 7
AABB

output:

8 9

result:

ok single line: '8 9'

Test #6:

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

input:

3 7
AABB

output:

8 9

result:

ok single line: '8 9'

Test #7:

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

input:

1 7
AABB

output:

8 9

result:

ok single line: '8 9'

Test #8:

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

input:

4 5
AABB

output:

-1

result:

ok single line: '-1'

Test #9:

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

input:

1 4
ABBA

output:

2 3

result:

ok single line: '2 3'

Test #10:

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

input:

3 6
ABBA

output:

4 5

result:

ok single line: '4 5'

Test #11:

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

input:

4 7
ABBA

output:

5 6

result:

ok single line: '5 6'

Test #12:

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

input:

5 9
ABBA

output:

-1

result:

ok single line: '-1'

Test #13:

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

input:

1 5
ABBA

output:

-1

result:

ok single line: '-1'

Test #14:

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

input:

2 7
ABBA

output:

-1

result:

ok single line: '-1'

Test #15:

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

input:

1 9
ABBA

output:

-1

result:

ok single line: '-1'

Test #16:

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

input:

2 8
BAAB

output:

1 9

result:

ok single line: '1 9'

Test #17:

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

input:

3 8
BAAB

output:

-1

result:

ok single line: '-1'

Test #18:

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

input:

2 6
BAAB

output:

-1

result:

ok single line: '-1'

Test #19:

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

input:

4 5
BAAB

output:

-1

result:

ok single line: '-1'

Test #20:

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

input:

6 8
ABAB

output:

7 9

result:

ok single line: '7 9'

Test #21:

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

input:

4 8
ABAB

output:

-1

result:

ok single line: '-1'

Test #22:

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

input:

3 7
ABAB

output:

-1

result:

ok single line: '-1'

Test #23:

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

input:

5 7
ABAB

output:

-1

result:

ok single line: '-1'

Test #24:

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

input:

1 3
ABAB

output:

-1

result:

ok single line: '-1'

Test #25:

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

input:

2 4
BABA

output:

1 3

result:

ok single line: '1 3'

Test #26:

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

input:

2 5
BABA

output:

-1

result:

ok single line: '-1'

Test #27:

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

input:

3 5
BABA

output:

-1

result:

ok single line: '-1'

Test #28:

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

input:

7 9
BABA

output:

-1

result:

ok single line: '-1'

Test #29:

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

input:

6 9
ABBA

output:

7 8

result:

ok single line: '7 8'

Test #30:

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

input:

2 5
BAAB

output:

-1

result:

ok single line: '-1'