QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#66110 | #5158. Interview Question | feeder1# | WA | 5ms | 6472kb | C++14 | 1.2kb | 2022-12-06 21:52:57 | 2022-12-06 21:53:00 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s[100001];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int a, b, fcnt = 0, bcnt = 0;
cin >> a >> b;
for (int i=a; i<=b; i++) {
cin >> s[i];
if (s[i] == "Fizz") fcnt++;
else if (s[i] == "Buzz") bcnt++;
else if (s[i] == "FizzBuzz") fcnt++, bcnt++;
}
int fans = 0, bans = 0;
if (fcnt == 0) fans = b + 1;
else if (fcnt == 1) {
for (int i=a; i<=b; i++) {
if (s[i] == "Fizz" || s[i] == "FizzBuzz") {
fans = i;
break;
}
}
} else {
int ss = -1, e = -1;
for (int i=a; i<=b; i++) {
if (s[i] == "Fizz" || s[i] == "FizzBuzz") {
if (ss == -1) ss = i;
else {
e = i;
fans = ss - e;
break;
}
}
}
}
if (bcnt == 0) bans = b + 1;
else if (bcnt == 1) {
for (int i=a; i<=b; i++) {
if (s[i] == "Buzz" || s[i] == "FizzBuzz") {
bans = i;
break;
}
}
} else {
int ss = -1, e = -1;
for (int i=a; i<=b; i++) {
if (s[i] == "Buzz" || s[i] == "FizzBuzz") {
if (ss == -1) ss = i;
else {
e = i;
bans = ss - e;
break;
}
}
}
}
cout << fans << ' ' << bans;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 4ms
memory: 6472kb
input:
7 11 7 8 Fizz Buzz 11
output:
9 10
result:
ok
Test #2:
score: -100
Wrong Answer
time: 5ms
memory: 6464kb
input:
49999 50002 49999 FizzBuzz 50001 Fizz
output:
-2 50000
result:
wrong answer Integer parameter [name=a] equals to -2, violates the range [1, 1000000]