제출 #730308

#제출 시각아이디문제언어결과실행 시간메모리
730308Desh03동굴 (IOI13_cave)C++17
0 / 100
53 ms340 KiB
#include <cave.h>
#include <bits/stdc++.h>
using namespace std;

void exploreCave(int n) {
    int v[n], d[n];
    int f = 0;
    while (f != n) {
        int l = f, r = n - 1;
        int s[n];
        for (int i = 0; i < n; i++) {
            if (d[i]) s[i] = v[i];
            else s[i] = 0;
        }
        int x = tryCombination(s), to_check;
        if (x == f) to_check = 0;
        else to_check = 1;
        for (int i = 0; i < n; i++) {
            if (d[i]) s[i] = v[i];
            else s[i] = to_check;
        }
        while (l < r) {
            int m = l + r >> 1;
            for (int i = l; i <= m; i++)
                if (!d[i]) s[i] ^= 1;
            x = tryCombination(s);
            if (x != f) {
                for (int i = l; i <= m; i++)
                    if (!d[i]) s[i] ^= 1;
                r = m;
            } else l = m + 1;
        }
        v[l] = to_check, d[l] = f++;
    }
    answer(v, d);
}

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

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:23:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   23 |             int m = 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...