QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#96267#5158. Interview QuestionSa3tElSefr#WA 45ms16916kbC++143.4kb2023-04-13 18:15:442023-04-13 18:15:45

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-13 18:15:45]
  • 评测
  • 测评结果:WA
  • 用时:45ms
  • 内存:16916kb
  • [2023-04-13 18:15:44]
  • 提交

answer

///Etfsh5t nseet el rank
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i, a, b) for (int i = a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define mp(x, y) make_pair(x, y)
#define popCnt(x) (__builtin_popcountll(x))
// #define int ll

using ll = long long;
using ull = unsigned long long;
using uint = uint32_t;
using ii = pair<int, int>;

const int N = 3e5 + 5, A = 12, LG = 18, MOD = (119 << 23) + 1;
const long double PI = acos(-1);
const long double EPS = 1e-9;
const int INF = 1e18;
vector<int> divos[100005];
string val[100005];
void doWork()
{
    int c, d;
    cin >> c >> d;
    vector<int> vec1, vec2;
    for (int i = c; i <= d; i++)
    {
        cin >> val[i];
    }
    f(i, c, d + 1)
    {
        if (val[i] == "Fizz" || val[i] == "FizzBuzz")
        {
            vec1 = divos[i];
            break;
        }
    }
    f(i, c, d + 1)
    {
        if (val[i] == "Buzz" || val[i] == "FizzBuzz")
        {
            vec2 = divos[i];
            break;
        }
    }

    f(i, c, d + 1)
    {
        vector<int> n_vec1, n_vec2;
        if (val[i] == "Fizz")
        {
            for (auto x : vec1)
            {
                if (i % x == 0)
                {
                    n_vec1.push_back(x);
                }
            }
            for (auto x : vec2)
            {
                if (i % x != 0)
                {
                    n_vec2.push_back(x);
                }
            }
        }
        else if (val[i] == "Buzz")
        {
            for (auto x : vec1)
            {
                if (i % x != 0)
                {
                    n_vec1.push_back(x);
                }
            }
            for (auto x : vec2)
            {
                if (i % x == 0)
                {
                    n_vec2.push_back(x);
                }
            }
        }
        else if (val[i] == "FizzBuzz")
        {
            for (auto x : vec1)
            {
                if (i % x == 0)
                {
                    n_vec1.push_back(x);
                }
            }
            for (auto x : vec2)
            {
                if (i % x == 0)
                {
                    n_vec2.push_back(x);
                }
            }
        }
        else
        {

            for (auto x : vec1)
            {
                if (i % x != 0)
                {
                    n_vec1.push_back(x);
                }
            }
            for (auto x : vec2)
            {
                if (i % x != 0)
                {
                    n_vec2.push_back(x);
                }
            }
        }
        vec1 = n_vec1;
        vec2 = n_vec2;
    }
    vec1.push_back(10000000);
    vec2.push_back(10000000);
    cout << vec1[0] << ' ' << vec2[0] << endl;
}
int32_t main()
{
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif // ONLINE_JUDGE

    for (int i = 1; i <= 100000; i++)
        for (int j = i; j <= 100000; j += i)
            divos[j].push_back(i);

    int t = 1;
    // cin >> t;
    while (t--)
    {
        doWork();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 32ms
memory: 16896kb

input:

7 11
7 8 Fizz Buzz 11

output:

3 5

result:

ok 

Test #2:

score: 0
Accepted
time: 44ms
memory: 16916kb

input:

49999 50002
49999 FizzBuzz 50001 Fizz

output:

2 4

result:

ok 

Test #3:

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

input:

8 11
Buzz Buzz FizzBuzz Buzz

output:

5 1

result:

ok 

Test #4:

score: -100
Wrong Answer
time: 45ms
memory: 16804kb

input:

10 15
10 11 12 13 14 15

output:

10000000 10000000

result:

wrong answer Integer parameter [name=a] equals to 10000000, violates the range [1, 1000000]