Submission #568581

#TimeUsernameProblemLanguageResultExecution timeMemory
568581stevancvCave (IOI13_cave)C++14
100 / 100
842 ms460 KiB
#include <bits/stdc++.h>
#include "cave.h"
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 2e5 + 2;
const int M = 5e5 + 2;
int mod = 1000000007;
int tryCombination(int S[]);
void answer(int S[], int D[]);
void exploreCave(int n) {
    int ans[n];
    int sw[n];
    for (int i = 0; i < n; i++) ans[i] = sw[i] = -1;
    for (int i = 0; i < n; i++) {
        int tmp[n];
        for (int j = 0; j < n; j++) {
            if (sw[j] == -1) tmp[j] = 0;
            else tmp[j] = sw[j];
        }
        int x = (tryCombination(tmp) == i);
        int l = 0, r = n - 1;
        while (l < r) {
            int mid = l + r >> 1;
            for (int j = 0; j <= mid; j++) {
                if (sw[j] == -1) tmp[j] = 1;
            }
            int y = (tryCombination(tmp) == i);
            if (x == y) l = mid + 1;
            else r = mid;
            for (int j = 0; j <= mid; j++) {
                if (sw[j] == -1) tmp[j] = 0;
            }
        }
        sw[l] = x;
        ans[l] = i;
    }
    answer(sw, ans);
}

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:28:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   28 |             int mid = l + r >> 1;
      |                       ~~^~~
#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...