Submission #528638

#TimeUsernameProblemLanguageResultExecution timeMemory
528638SharkyCave (IOI13_cave)C++17
0 / 100
210 ms332 KiB
#ifdef __cplusplus
extern "C" {
#endif
int tryCombination(int S[]);
void answer(int S[], int D[]);
void exploreCave(int N);
#ifdef __cplusplus
}
#endif

#include <bits/stdc++.h>
using namespace std;
#define ask(x) tryCombination(x)
void exploreCave(int n) {
    int S[n], D[n], a[n];
    bool flag[n]; fill(flag, flag + n, false);
    fill(a, a + n, 0); // query with a, answer with S
    for (int i = 0; i < n; i++) {
        int prev = ask(a);
        if (prev == i) S[i] = 1;
        else S[i] = 0;
        int l = 0, r = n;
        while (l <= r) {
            if (l == r) {
                flag[l] = true; D[i] = l; break; 
            }
            int m = (l + r) >> 1;
            for (int i = l; i < r; i++) if (!flag[i]) a[i] = S[i];
            // if seg of S[i] is closed, it's the other side
            prev = ask(a);
            for (int i = m; i < r; i++) if (!flag[i]) a[i] = 0;
            if (prev != i) r = m - 1;
            else l = m + 1;
        }
    }
    answer(S, D);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...