QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#66110#5158. Interview Questionfeeder1#WA 5ms6472kbC++141.2kb2022-12-06 21:52:572022-12-06 21:53:00

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-06 21:53:00]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:6472kb
  • [2022-12-06 21:52:57]
  • 提交

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]