QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#872834#5158. Interview QuestionMini Soda (Enze Zhang, Guanlin Chen, Xinchen Shen)#WA 1ms3712kbC++201.5kb2025-01-26 05:22:102025-01-26 05:22:11

Judging History

This is the latest submission verdict.

  • [2025-01-26 05:22:11]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3712kb
  • [2025-01-26 05:22:10]
  • Submitted

answer

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, m;
    cin >> n >> m;

    vector<int> a, b, c;
    for (int i = n; i <= m; i++) {
        string s;
        cin >> s;

        if (s == "Fizz") {
            a.push_back(i);
        }
        if (s == "Buzz") {
            b.push_back(i);
        }
        if (s == "FizzBuzz") {
            c.push_back(i);
        }
    }

    int A = 0, B = 0, C = 0;
    for(int i = 0; i < a.size(); i++){
        A = __gcd(A, a[i]);
    }
    for(int i = 0; i < b.size(); i++){
        B = __gcd(B, b[i]);
    }
    for(int i = 0; i < c.size(); i++){
        C = __gcd(C, c[i]);
    }

    if (!c.empty()) {
        if (!a.empty() && !b.empty()) {
            cout << __gcd(A, C) << " " << __gcd(B, C) << endl;
        } else if (!a.empty()) {
            cout << __gcd(A, C) << " " << C / __gcd(A, C) << endl;
        } else if (!b.empty()) {
            cout << C / __gcd(B, C) << " " << __gcd(B, C) << endl;
        } else {
            cout << 1 << " " << C << endl;
        }
    }
    else{
        if(!a.empty() && !b.empty()){
            cout << A << " " << B << endl;
        }
        else if(!a.empty()){
            cout << A << " " << m + 1 << endl;
        }
        else if(!b.empty()){
            cout << m + 1 << " " << B << endl;
        }
        else{
            cout << m + 1 << " " << m + 2 << endl;
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

7 11
7 8 Fizz Buzz 11

output:

9 10

result:

ok 

Test #2:

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

input:

49999 50002
49999 FizzBuzz 50001 Fizz

output:

2 25000

result:

ok 

Test #3:

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

input:

8 11
Buzz Buzz FizzBuzz Buzz

output:

10 1

result:

ok 

Test #4:

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

input:

10 15
10 11 12 13 14 15

output:

16 17

result:

ok 

Test #5:

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

input:

17 17
17

output:

18 19

result:

ok 

Test #6:

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

input:

13 13
Fizz

output:

13 14

result:

ok 

Test #7:

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

input:

20 20
Buzz

output:

21 20

result:

ok 

Test #8:

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

input:

30 30
FizzBuzz

output:

1 30

result:

ok 

Test #9:

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

input:

9 10
Buzz FizzBuzz

output:

10 1

result:

ok 

Test #10:

score: -100
Wrong Answer
time: 0ms
memory: 3584kb

input:

2 6
2 3 4 5 FizzBuzz

output:

1 6

result:

FAIL Mismatch at position 2: expected 2, got Fizz