제출 #1044784

#제출 시각아이디문제언어결과실행 시간메모리
1044784c2zi6COVID tests (CEOI24_covid)C++14
0 / 100
159 ms424 KiB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef vector<bool> VB;
 
int N;
double P;
VB iskakan;
int q;
 
bool test_students(std::vector<bool> mask) {
    q++;
    rep(i, N) if (mask[i] && iskakan[i]) return true;
    return false;
 
    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';
}
 
int cnt;
mt19937 rng;

map<ld, int> segsz = {
    {1, 1000},
    {5, 1000},
    {11, 70},
    {28, 30},
    {39, 15},
    {68, 10},
    {104, 9},
    {158, 9},
    {200, 9}
};

VB find_positive() {
    int n = N;
    if (true) {
        iskakan = VB(n);
        q = 0;
        int lim = P * 1000000;
        rep(i, n) iskakan[i] = (rng()%1000000 <= lim);
    }
    int cnt = segsz[int(1000*P)];
    if (P > 0.2) {
        VB answer(n);
        rep(i, n) {
            VB mask(n);
            mask[i] = true;
            if (test_students(mask)) answer[i] = true;
        }
        return answer;
    } else {
        VB answer(n);
        int mek = int(1000 * P);
        VPI seg;
        for (int l = 0; l < n;) {
            if (l+cnt > n-1) {
                seg.pb({l, n-1});
                break;
            }
            seg.pb({l, l+cnt});
            l = l+cnt+1;
        }
        for (auto[L, R] : seg) {
            int last = L-1;
            while (true) {
                if (int(1000*P) < 158) {
                    VB query(n);
                    replr(i, L, R) query[i] = (true && !answer[i]);
                    if (!test_students(query)) break;
                }

                int l = last, r = R+1;
                while (l + 1 < r) {
                    int m = (l + r) / 2;
                    VB query(n);
                    replr(i, 0, m) query[i] = (true && !answer[i]);
                    bool f = test_students(query);
                    if (f) r = m;
                    else l = m;
                }
                if (r == R+1) break;
                last = r;
                answer[r] = true;
            }
        }
        return answer;
    }
    return VB();
}
 

ld PARR[9], FARR[9];

void init() {
    PARR[0] = 0.001000l; FARR[0] = 15.10l;
    PARR[1] = 0.005256l; FARR[1] = 51.10l;
    PARR[2] = 0.011546l; FARR[2] = 94.90l;
    PARR[3] = 0.028545l; FARR[3] = 191.5l;
    PARR[4] = 0.039856l; FARR[4] = 246.3l;
    PARR[5] = 0.068648l; FARR[5] = 366.2l;
    PARR[6] = 0.104571l; FARR[6] = 490.3l;
    PARR[7] = 0.158765l; FARR[7] = 639.1l;
    PARR[8] = 0.200000l; FARR[8] = 731.4l;
}

/*
 * 1000
 * 1000
 * 70
 * 30
 * 15
 * 10
 * 9
 * 9
 * 9
 */

int main() {
    init();
    rng = mt19937(chrono::steady_clock().now().time_since_epoch().count());
    int T = 200;
    N = 1000;
    ld F;
    /*scanf("%d %lf %d", &N, &P, &T);*/
    /*scanf("%lf", &P);*/
    /*replr(ind, 0, 8) {*/
    replr(ind, 6, 6) {
        P = PARR[ind];
        F = FARR[ind];
        cout << "RUNNING WITH " << P << " " << F << endl;
        /*for (cnt = 2; cnt <= 11; cnt++) {*/
        for (cnt = 1; cnt <= 15; cnt += 3) {
        /*{*/
            cout << "cnt: " << cnt << ", ";
            int average = 0;
            for (int i = 0; i < T; i++) {
                std::vector<bool> answer = find_positive();
                /*cout << q << endl;*/
                average += q;
                continue;

                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);
            }
            ld Q = ld(average)/T;
            /*cout << Q << endl;*/
            /*cout << min(ld(90), 90 * F / (F + 4 * (Q - F))) << endl;*/
            if (Q < F) cout << 90 << endl;
            else cout << 90 * F / (F + 4 * (Q - F)) << endl;
        }
    }
    return 0;
}
 

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'VB find_positive()':
Main.cpp:76:47: warning: comparison of integer expressions of different signedness: 'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::result_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   76 |         rep(i, n) iskakan[i] = (rng()%1000000 <= lim);
      |                                 ~~~~~~~~~~~~~~^~~~~~
Main.cpp:99:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   99 |         for (auto[L, R] : seg) {
      |                  ^
Main.cpp:89:13: warning: unused variable 'mek' [-Wunused-variable]
   89 |         int mek = int(1000 * P);
      |             ^~~
Main.cpp: In function 'bool test_students(std::vector<bool>)':
Main.cpp:51:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |     scanf(" %c", &answer);
      |     ~~~~~^~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:185:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  185 |                 scanf(" %c", &verdict);
      |                 ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...