QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#517067#9162. COVID testsskittles141290 1591ms12288kbC++177.1kb2024-08-13 05:09:352024-08-13 05:09:35

Judging History

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

  • [2024-08-13 05:09:35]
  • 评测
  • 测评结果:90
  • 用时:1591ms
  • 内存:12288kb
  • [2024-08-13 05:09:35]
  • 提交

answer

// cf bits/extc++.h nonsense
#ifdef ONLINE_JUDGE
#define _EXT_CODECVT_SPECIALIZATIONS_H 1
#define _EXT_ENC_FILEBUF_H 1
#endif
#include "bits/extc++.h"

using namespace std;

template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
    cerr << t;
    ((cerr << " | " << u), ...);
    cerr << endl;
}

#ifdef DEBUG
#define dbg(...)                                              \
    cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \
    dbgh(__VA_ARGS__)
#else
#define dbg(...)
#define cerr   \
    if (false) \
    cerr
#endif

using u64 = uint64_t;
using ll = long long;
using ld = long double;

template <typename T>
using min_pq = priority_queue<T, vector<T>, greater<T>>;

#define endl "\n"
#define long int64_t
#define sz(x) int(std::size(x))

inline void init_io() {
    cin.tie(nullptr);
    cin.exceptions(ios::failbit);
    ios_base::sync_with_stdio(false);
}

template <typename T>
vector<T> iota(int n, const T& init) {
    vector<T> arr(n);

    iota(begin(arr), end(arr), init);

    return arr;
}

template <typename T>
vector<vector<T>> transposed(const vector<vector<T>>& arr) {
    int n = sz(arr), m = sz(arr[0]);

    vector ans(m, vector<T>(n));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            ans[j][i] = arr[i][j];
        }
    }

    return ans;
}

template <typename T>
bool on(const T& mask, int bit) {
    return (mask >> bit) & 1;
}

template <typename T>
ostream& operator<<(ostream& out, const vector<T>& arr) {
    out << "[";
    for (int i = 0; i < sz(arr); i++) {
        if (i) {
            out << ", ";
        }
        out << arr[i];
    }
    return out << "]";
}

template <typename A, typename B>
ostream& operator<<(ostream& out, const pair<A, B>& p) {
    return out << "(" << p.first << ", " << p.second << ")";
}

template <typename A, typename T>
int lbs(const A& arr, const T& x) {
    return int(lower_bound(begin(arr), end(arr), x) - begin(arr));
}

inline vector<bool>::reference& operator&=(vector<bool>::reference&& a, bool b) {
    return a = a & b;
}

template <typename T>
T reversed(T arr) {
    reverse(begin(arr), end(arr));
    return arr;
}

/// You may use:

// The number of students
int N, n;

// The probability any given student is positive
double P, p;

// This function performs a test on a subset of samples.
// Its argument is a vector of Booleans of length N,
// where the i-th element is true if the i-th sample should be added to the mix.
// It returns true if (and only if) at least one of the samples in the mix is
// positive.
bool test_students(std::vector<bool> mask) {
    assert(mask.size() == (size_t)N);

    std::string mask_str(N, ' ');
    for (int i = 0; i < N; i++)
        mask_str[i] = mask[i] ? '1' : '0';

    printf("Q %s\n", mask_str.c_str());
    fflush(stdout);

    char answer;
    scanf(" %c", &answer);
    return answer == 'P';
}

bool query_inter(int ql, int len) {
    vector<bool> cq(n);

    fill_n(begin(cq) + ql, len, true);

    return test_students(cq);
}

vector<float> dp2, pcomp1;
vector<vector<float>> dp1, pcomp2;

// prob of m things having a 1 in them
float prob1(int m) {
    return pcomp1[m];
}

// probability of a 1 being in first m things if tot things have a 1 in them
float prob2(int m, int tot) {
    return pcomp2[m][tot];
    // return prob1(m) / prob1(tot);
};

void pcomp() {
    pcomp1 = vector(n + 1, float(0));
    for (int m = 0; m <= n; m++) {
        pcomp1[m] = 1 - pow(1 - p, m);
    }

    pcomp2 = vector(n + 1, vector(n + 1, float(0)));
    for (int m = 0; m <= n; m++) {
        for (int tot = m; tot <= n; tot++) {
            pcomp2[m][tot] = prob1(m) / prob1(tot);
        }
    }

    dp2 = vector(n + 1, float(1e9));
    dp1 = vector(n + 1, vector(n + 1, float(1e9)));
    dp2[0] = 0;

    for (int tot = 1; tot <= n; tot++) {
        for (int extra = tot - 1; extra >= 0; extra--) {
            int cur = tot - extra;

            if (cur == 1) {
                assert(dp2[extra] < 1e8);
                dp1[extra][cur] = dp2[extra];
            }

            for (int i = 1; i < cur; i++) {
                float cp = prob2(i, cur);

                assert(dp1[extra + cur - i][i] < 1e8);
                assert(dp1[extra][cur - i] < 1e8);
                dp1[extra][cur] =
                    min(dp1[extra][cur], 1 + cp * (dp1[extra + cur - i][i]) +
                                             (1 - cp) * dp1[extra][cur - i]);
            }
        }

        for (int i = 1; i <= tot; i++) {
            float cp = prob1(i);

            assert(dp1[tot - i][i] < 1e8);
            assert(dp2[tot - i] < 1e8);
            dp2[tot] = min(dp2[tot],
                           1 + cp * dp1[tot - i][i] + (1 - cp) * dp2[tot - i]);
        }
    }
    dbg(dp2);
    dbg(dp1);
}

/// You should implement:

// This function will be called once for each test instance.
// It should use test_students to determine which samples are positive.
// It must return a vector of Booleans of length N,
// where the i-th element is true if and only if the i-th sample is positive.
vector<bool> find_positive() {
    vector<bool> ans(n);

    int ind = 0;
    while (ind < n) {
        int tot = n - ind;

        pair opt {float(1e9), -1};

        for (int i = 1; i <= tot; i++) {
            float cp = prob1(i);

            assert(dp1[tot - i][i] < 1e8);
            assert(dp2[tot - i] < 1e8);
            opt = min(opt,
                      {1 + cp * dp1[tot - i][i] + (1 - cp) * dp2[tot - i], i});
        }

        if (!query_inter(ind, opt.second)) {
            ind += opt.second;
            continue;
        }

        int cur = opt.second, extra = tot - cur;
        while (cur > 1) {
            opt = {float(1e9), -1};

            for (int i = 1; i < cur; i++) {
                float cp = prob2(i, cur);

                assert(dp1[extra + cur - i][i] < 1e8);
                assert(dp1[extra][cur - i] < 1e8);
                opt = min(opt, {1 + cp * (dp1[extra + cur - i][i]) +
                                    (1 - cp) * dp1[extra][cur - i],
                                i});
            }

            int i = opt.second;
            if (query_inter(ind, i)) {
                extra += cur - i;
                cur = i;
            } else {
                ind += i;
                cur -= i;
            }
        }

        ans[ind] = true;
        ind++;
    }

    return ans;
}

int main() {
    int T;
    scanf("%d %lf %d", &N, &P, &T);
    n = N;
    p = P;
    pcomp();

    // You may perform any extra initialization here.

    for (int i = 0; i < T; i++) {
        std::vector<bool> answer = find_positive();
        assert(answer.size() == (size_t)N);

        std::string answer_str(N, ' ');
        for (int j = 0; j < N; j++)
            answer_str[j] = answer[j] ? '1' : '0';

        printf("A %s\n", answer_str.c_str());
        fflush(stdout);

        char verdict;
        scanf(" %c", &verdict);
        if (verdict == 'W')
            exit(0);
    }

    return 0;
}

详细

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 10
Accepted
time: 472ms
memory: 11980kb

input:

1000 0.789673 1
P
N
P
P
P
P
P
P
N
P
P
N
P
N
P
P
P
P
P
N
P
P
P
P
P
P
N
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
N
N
N
P
P
P
P
N
P
P
P
P
N
N
P
P
P
N
P
P
P
P
N
P
P
P
P
P
N
N
P
N
P
P
P
P
P
N
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
N
N
P
N
P
P
P
P
P
P
P
P
N
P
N
P
P
P
N
N
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
N
...

output:

Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 translate:success

Test #2:

score: 10
Accepted
time: 473ms
memory: 12220kb

input:

1000 0.686378 1
N
P
N
N
N
P
N
N
P
N
P
P
N
N
P
P
P
P
N
P
P
P
N
P
P
P
N
N
P
N
P
P
P
N
N
N
P
N
P
P
P
N
P
P
P
P
P
P
N
N
P
P
P
N
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
N
N
P
P
N
N
N
P
P
N
P
N
P
P
P
P
P
N
P
N
N
P
P
P
N
P
N
N
P
N
P
P
P
P
N
P
N
P
P
P
P
N
P
P
N
P
P
P
N
P
N
P
P
N
P
N
N
P
P
N
P
N
P
P
N
N
P
N
N
P
...

output:

Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 translate:success

Test #3:

score: 10
Accepted
time: 464ms
memory: 12044kb

input:

1000 0.873862 1
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
N
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
N
P
P
P
P
P
P
P
P
P
N
P
P
P
P
P
P
P
P
P
P
P
P
P
N
P
P
P
P
P
P
P
P
P
N
P
P
P
N
P
P
N
P
P
P
P
P
P
N
P
P
P
P
P
N
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
N
P
P
P
P
P
N
P
P
N
P
P
P
P
P
P
P
P
...

output:

Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 translate:success

Test #4:

score: 10
Accepted
time: 469ms
memory: 12220kb

input:

1000 0.669578 1
P
P
N
P
P
P
P
P
N
P
N
P
P
P
N
P
P
P
P
P
P
P
N
P
P
P
P
N
N
P
N
P
N
P
P
N
P
P
N
P
P
N
P
N
P
P
P
P
P
P
P
P
P
P
P
P
P
N
N
P
P
N
P
P
N
N
P
P
N
N
P
N
P
N
P
N
P
P
N
N
P
P
P
P
P
P
P
P
P
P
N
P
P
N
P
P
N
P
P
P
P
P
P
N
P
P
P
P
N
N
N
P
N
P
P
N
P
P
N
N
P
P
N
P
P
P
N
P
P
N
P
P
P
P
P
N
P
P
N
P
P
P
...

output:

Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 translate:success

Test #5:

score: 10
Accepted
time: 456ms
memory: 12060kb

input:

1000 0.907052 1
P
P
P
P
P
P
P
N
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
N
P
P
P
P
N
P
P
P
P
P
P
P
P
P
P
P
P
N
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
N
P
P
P
P
P
N
P
P
P
P
P
P
P
P
P
N
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
N
P
P
P
N
P
P
P
P
N
N
P
...

output:

Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 translate:success

Test #6:

score: 10
Accepted
time: 471ms
memory: 12020kb

input:

1000 0.844418 1
P
P
P
P
P
P
P
P
P
P
P
P
N
P
P
P
P
P
P
N
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
N
P
P
P
P
P
N
P
P
P
N
P
P
P
P
P
N
P
P
P
P
P
P
N
P
P
P
N
P
N
P
P
N
P
P
P
N
P
P
N
P
P
P
N
N
N
P
P
P
P
N
N
P
N
N
P
P
P
P
P
P
P
N
P
N
P
P
P
P
N
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
...

output:

Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 translate:success

Test #7:

score: 10
Accepted
time: 464ms
memory: 11980kb

input:

1000 0.533576 1
P
P
P
N
N
N
N
P
P
N
N
P
N
P
N
P
P
N
P
N
N
P
N
P
N
P
P
N
P
N
P
N
P
P
P
P
N
N
N
P
P
P
P
P
N
N
P
P
N
P
P
P
P
P
N
P
P
P
P
N
N
N
N
N
P
N
P
P
P
N
P
N
P
P
P
N
P
P
P
P
N
P
N
P
P
N
N
P
N
N
P
N
P
P
N
N
P
N
P
P
N
N
P
N
N
P
N
N
P
P
N
N
N
N
P
N
P
N
N
P
N
N
P
P
N
P
P
P
P
P
N
N
N
P
P
N
P
N
P
N
P
P
...

output:

Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 translate:success

Test #8:

score: 10
Accepted
time: 476ms
memory: 12288kb

input:

1000 0.415944 1
N
N
N
N
N
N
N
P
N
N
P
N
N
P
N
P
N
N
N
P
N
N
N
N
N
N
N
N
N
P
N
N
N
N
P
P
P
P
N
P
N
N
P
N
N
P
N
N
P
P
N
P
P
P
N
N
P
N
P
N
N
N
N
N
P
N
P
N
P
N
P
N
N
N
P
N
N
N
N
P
N
N
P
P
P
P
P
N
N
N
P
P
N
N
N
P
N
N
P
N
P
P
P
N
P
P
N
P
P
P
N
P
N
P
P
P
P
P
N
N
N
P
P
P
P
P
P
P
P
N
N
N
P
P
N
N
N
N
N
N
P
P
...

output:

Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 translate:success

Test #9:

score: 10
Accepted
time: 465ms
memory: 12064kb

input:

1000 0.596017 1
P
N
P
P
N
N
P
N
N
P
P
P
N
P
N
N
P
P
P
N
P
N
P
N
N
N
P
N
N
P
N
N
P
N
P
P
P
N
P
P
N
P
P
P
N
P
N
P
P
P
N
P
N
N
P
P
P
N
P
N
N
N
P
N
N
N
P
P
P
N
P
P
P
N
N
P
N
N
P
P
N
N
P
N
P
N
N
P
N
N
P
N
P
P
N
N
P
P
P
P
N
P
P
P
N
N
P
P
P
P
P
P
N
P
P
P
N
P
P
N
P
P
P
P
P
P
P
P
N
P
P
P
P
N
N
P
P
P
N
P
N
P
...

output:

Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 translate:success

Test #10:

score: 10
Accepted
time: 465ms
memory: 12176kb

input:

1000 0.157686 1
N
N
N
P
P
N
P
N
N
P
P
P
P
N
P
N
P
P
P
N
N
P
N
N
P
N
N
P
P
P
P
N
P
P
P
N
N
P
P
N
N
N
N
N
P
N
P
N
N
N
P
N
N
P
P
P
N
P
N
N
P
P
P
N
N
P
P
N
P
P
P
P
P
P
P
P
P
N
N
N
N
P
N
P
P
N
P
N
P
P
N
N
P
P
N
N
P
N
N
N
N
N
P
P
P
N
P
P
N
P
P
N
N
P
N
P
P
N
P
N
N
N
P
N
P
N
N
N
P
P
N
N
P
P
N
P
P
N
N
N
N
P
...

output:

Q 1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 translate:success

Test #11:

score: 10
Accepted
time: 477ms
memory: 12180kb

input:

1000 0.380215 1
N
P
N
N
P
N
N
P
P
N
P
N
P
P
P
N
N
P
N
P
P
P
P
P
N
P
P
N
P
N
N
P
N
N
P
N
P
P
P
P
P
P
N
N
P
N
P
P
N
N
N
N
N
N
N
P
P
P
P
N
N
P
P
P
P
N
P
N
N
N
P
N
P
N
N
P
P
N
N
P
P
N
N
P
P
P
P
P
P
P
P
P
P
P
P
P
P
N
N
N
N
N
P
P
N
P
P
N
P
N
N
N
N
N
P
N
P
N
P
N
N
P
P
P
P
N
P
P
P
P
N
N
P
P
P
P
N
N
P
N
P
N
...

output:

Q 1100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 translate:success

Test #12:

score: 10
Accepted
time: 473ms
memory: 12028kb

input:

1000 0.432565 1
P
N
P
N
N
P
N
N
N
P
P
P
N
P
P
N
N
N
N
N
N
N
N
N
P
P
P
N
P
P
N
N
P
P
P
P
N
P
P
N
N
N
N
P
P
P
P
N
P
N
N
P
P
P
N
N
N
N
P
N
P
N
P
N
P
N
P
P
N
N
P
N
N
P
N
N
N
P
N
P
N
N
N
P
N
N
P
N
P
N
N
N
P
N
N
P
P
P
P
P
P
N
P
N
N
N
N
N
N
N
P
P
N
P
N
N
N
N
P
P
P
N
P
N
N
P
P
P
N
P
P
P
P
P
P
N
P
N
P
P
N
P
...

output:

Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 translate:success

Test #13:

score: 10
Accepted
time: 468ms
memory: 11976kb

input:

1000 0.509199 1
P
P
N
P
N
N
N
P
P
N
N
N
N
N
P
N
N
P
P
N
P
P
N
P
P
P
P
P
N
N
P
N
P
P
N
P
P
P
P
P
P
P
P
P
P
N
P
P
P
N
N
P
N
P
P
N
P
N
P
N
N
P
N
P
N
P
N
N
N
N
N
P
P
N
N
N
P
P
P
N
N
P
P
P
P
N
N
N
N
P
P
N
P
N
N
N
P
P
P
P
P
N
N
N
P
P
N
P
P
N
P
N
P
P
P
N
N
P
P
N
N
N
N
N
N
P
P
P
N
N
P
P
N
N
N
N
N
N
P
P
N
N
...

output:

Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 translate:success

Test #14:

score: 10
Accepted
time: 465ms
memory: 12028kb

input:

1000 0.381646 1
N
P
N
N
N
P
P
P
P
P
P
N
N
P
N
N
P
N
P
N
P
N
P
N
N
N
N
P
N
P
P
N
N
P
P
P
P
N
N
P
N
N
N
P
P
P
N
N
N
P
P
P
P
P
P
P
N
P
P
P
N
P
P
P
P
P
N
P
N
P
P
P
P
N
N
P
N
N
P
P
P
P
P
N
P
P
P
N
P
P
N
N
P
P
P
P
N
P
P
N
N
P
N
N
P
P
P
P
N
N
P
N
P
P
P
N
N
P
P
N
P
N
P
P
N
P
P
N
N
P
P
P
P
N
N
P
N
P
P
P
P
N
...

output:

Q 1100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 translate:success

Test #15:

score: 10
Accepted
time: 461ms
memory: 12016kb

input:

1000 0.42815 1
N
P
P
N
P
N
P
P
P
N
N
P
N
N
P
N
N
P
P
P
N
N
N
N
P
P
P
N
N
N
P
P
N
P
N
N
P
N
N
N
P
P
N
N
N
N
P
N
N
P
P
N
P
N
N
N
N
P
N
N
N
N
N
P
N
P
P
N
P
P
P
P
N
N
N
P
P
P
N
P
P
P
N
P
P
N
P
N
N
N
P
N
N
P
N
N
P
P
N
P
P
N
N
P
N
N
P
P
P
P
P
P
P
N
N
N
P
N
P
N
P
N
N
N
N
N
N
N
P
N
N
N
P
N
P
P
P
P
N
N
N
P
N...

output:

Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 translate:success

Test #16:

score: 10
Accepted
time: 474ms
memory: 11984kb

input:

1000 1 1
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P...

output:

Q 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 translate:success

Test #17:

score: 0
Runtime Error

input:

1000 0 1

output:


result:


Subtask #2:

score: 90
Accepted

Test #18:

score: 90
Accepted
time: 496ms
memory: 12224kb

input:

1000 0.001 300
N
N
C
N
P
P
N
N
P
P
N
N
P
P
N
C
N
P
N
P
N
P
N
N
P
P
P
P
P
N
P
P
N
P
N
P
P
P
N
N
N
P
N
N
C
N
N
C
N
N
C
P
N
P
N
P
N
P
P
N
N
N
C
N
P
N
P
P
N
P
P
N
P
P
N
C
N
N
C
N
N
C
P
N
P
P
P
P
P
N
P
P
N
C
N
N
C
N
P
N
P
N
P
N
P
N
N
P
P
N
P
P
P
P
N
N
N
C
N
P
P
N
P
N
P
P
P
P
N
P
P
N
P
P
P
N
P
P
P
N
P
P
P...

output:

Q 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

points 1.0 1.0 Output is correct (P=0.001, F=15.1, Q=10.8) -> 90.00 points

Test #19:

score: 90
Accepted
time: 543ms
memory: 12004kb

input:

1000 0.005256 300
P
N
P
N
N
N
P
N
P
P
P
P
N
P
P
N
N
N
P
N
P
P
N
N
P
N
N
N
P
N
P
P
P
N
P
P
N
P
N
P
N
P
N
P
P
N
C
N
N
N
N
P
N
P
N
P
N
P
N
N
P
N
N
N
P
N
P
P
P
P
N
N
P
N
P
N
N
C
N
N
N
N
N
N
N
P
P
N
N
P
P
P
P
N
C
N
P
P
P
N
P
N
N
P
N
P
P
P
P
N
N
N
P
P
P
P
P
P
N
P
N
N
N
N
P
P
N
N
P
N
P
N
N
P
N
P
N
N
P
N
N
...

output:

Q 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 Output is correct (P=0.005256, F=51.1, Q=46.3) -> 90.00 points

Test #20:

score: 90
Accepted
time: 617ms
memory: 12164kb

input:

1000 0.011546 300
P
P
N
P
N
P
P
P
P
P
N
N
P
P
N
N
N
P
N
P
P
N
P
N
N
P
P
P
P
N
N
P
P
P
P
P
N
P
P
P
P
P
N
P
P
N
N
N
N
N
P
P
P
N
P
N
N
N
N
N
N
N
N
N
P
N
N
P
P
P
N
P
N
P
N
N
N
P
N
P
P
P
N
N
N
P
P
N
P
P
P
P
P
N
C
N
P
N
P
N
P
P
N
N
N
N
N
P
P
N
N
P
N
P
N
N
N
N
N
N
N
P
N
P
P
N
P
P
N
N
P
P
P
P
N
P
N
N
C
P
P
...

output:

Q 1111111111111111111111111111111111111111111111111111111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 Output is correct (P=0.011546, F=94.9, Q=90.5) -> 90.00 points

Test #21:

score: 90
Accepted
time: 800ms
memory: 12012kb

input:

1000 0.028545 300
P
P
P
P
P
N
N
N
P
P
N
N
P
N
N
P
P
N
N
N
P
P
P
N
N
N
N
P
N
N
N
N
P
P
P
P
N
N
N
P
P
P
P
N
N
N
N
P
N
N
N
N
N
P
N
N
N
P
P
P
N
P
N
N
P
P
N
P
N
P
P
P
N
N
N
P
N
P
P
P
P
P
P
P
N
N
P
P
P
N
P
P
N
P
N
N
N
P
N
N
N
P
N
N
P
N
N
N
P
N
N
N
P
N
P
N
P
N
P
P
P
N
N
P
N
N
N
N
P
N
N
N
P
P
N
N
P
N
P
N
P
...

output:

Q 1111111111111111111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 Output is correct (P=0.028545, F=191.5, Q=187.7) -> 90.00 points

Test #22:

score: 90
Accepted
time: 800ms
memory: 12020kb

input:

1000 0.039856 300
P
N
P
P
N
N
P
P
P
N
P
P
P
P
N
N
N
N
N
N
N
N
N
P
P
N
P
P
N
P
N
P
P
P
P
P
P
P
N
P
P
N
P
N
P
P
N
N
P
P
P
N
N
N
P
P
P
N
N
N
N
P
P
N
P
N
P
N
N
N
N
P
P
N
N
N
N
N
P
N
N
N
N
N
N
P
P
N
P
N
N
N
N
N
N
N
P
N
P
N
P
N
P
N
P
N
P
N
P
N
N
N
N
N
N
P
N
P
P
P
N
P
N
N
P
N
N
P
P
P
P
P
P
P
P
P
P
P
P
P
N
...

output:

Q 1111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 Output is correct (P=0.039856, F=246.3, Q=243.7) -> 90.00 points

Test #23:

score: 90
Accepted
time: 961ms
memory: 12168kb

input:

1000 0.068648 300
N
P
N
P
P
P
P
N
N
P
P
N
N
P
P
P
P
N
P
P
P
N
P
P
P
P
P
P
P
N
P
N
N
N
P
P
N
P
P
N
N
P
P
N
P
P
N
N
N
P
P
N
N
N
P
N
N
P
N
P
N
N
N
P
P
P
N
N
N
N
N
N
N
P
N
N
N
N
P
N
N
N
P
P
P
P
P
P
P
P
P
N
P
P
N
N
N
P
N
N
N
N
N
P
P
P
N
N
N
P
N
N
P
P
P
N
N
N
P
N
N
N
P
P
P
N
P
N
P
N
P
N
P
N
N
N
P
N
P
N
P
...

output:

Q 1111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 Output is correct (P=0.068648, F=366.2, Q=364.2) -> 90.00 points

Test #24:

score: 90
Accepted
time: 1225ms
memory: 12060kb

input:

1000 0.104571 300
N
N
N
P
N
P
N
N
N
P
P
P
P
P
N
P
P
P
N
N
N
P
N
P
P
P
N
P
P
P
N
N
N
P
N
P
P
N
P
P
P
P
N
P
P
P
P
P
N
P
P
P
P
P
N
N
N
N
N
N
P
N
P
N
N
N
P
N
P
N
N
N
P
N
N
P
N
N
N
N
P
N
N
P
P
P
N
P
N
P
N
P
N
P
P
P
N
P
N
N
P
N
N
P
N
P
N
N
P
N
N
P
N
N
P
P
N
P
P
P
P
P
P
N
N
P
P
N
N
N
P
N
P
N
N
P
N
P
P
N
P
...

output:

Q 1111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 Output is correct (P=0.104571, F=490.3, Q=488.2) -> 90.00 points

Test #25:

score: 90
Accepted
time: 1425ms
memory: 12008kb

input:

1000 0.158765 300
N
N
N
N
P
P
P
N
P
P
N
N
N
P
P
N
P
P
P
N
N
N
N
N
N
N
N
P
N
N
P
P
N
N
N
N
N
P
P
N
N
N
N
P
P
N
N
N
N
P
N
N
N
P
N
N
N
N
P
N
P
N
N
N
P
N
P
P
N
P
N
P
P
P
N
P
N
P
N
N
N
N
N
N
P
P
P
P
P
P
P
P
P
N
N
P
P
N
N
N
N
N
N
P
N
N
N
N
P
P
N
P
N
P
P
P
P
P
P
N
P
N
N
N
P
N
P
P
N
N
P
N
P
N
P
P
N
P
N
P
N
...

output:

Q 1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 Output is correct (P=0.158765, F=639.1, Q=633.1) -> 90.00 points

Test #26:

score: 90
Accepted
time: 1591ms
memory: 12008kb

input:

1000 0.2 300
N
P
N
P
N
P
N
P
P
N
P
N
N
N
N
N
P
N
N
P
N
P
P
P
N
P
N
P
P
N
P
P
N
N
P
N
P
N
P
P
P
N
P
N
P
P
P
P
N
P
N
N
P
N
N
N
N
N
N
P
N
N
P
P
P
P
N
P
N
N
N
P
N
N
N
P
P
N
P
P
N
N
N
N
P
N
P
P
N
P
P
P
P
N
N
N
N
P
P
P
P
P
N
P
P
N
N
N
P
N
N
P
N
P
P
N
P
N
N
N
N
P
N
P
P
P
P
P
P
N
N
N
N
P
N
P
N
N
N
P
N
P
N
N...

output:

Q 1110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

points 1.0 1.0 Output is correct (P=0.2, F=731.4, Q=729.3) -> 90.00 points