제출 #716700

#제출 시각아이디문제언어결과실행 시간메모리
716700aykhnCave (IOI13_cave)C++14
0 / 100
200 ms444 KiB
#include <bits/stdc++.h>
#include "cave.h"

using namespace std;

typedef long long ll;

#define OPT ios_base::sync_with_stdio(0); \
            cin.tie(0); \
            cout.tie(0)

#define pii pair<int,int>
#define pll pair<ll,ll>
#define endl "\n"
#define all(v) v.begin(), v.end()
#define mpr make_pair
#define pb push_back
#define ts to_string
#define fi first
#define se second
#define inf 0x3F3F3F3F
#define bpc __builtin_popcount
#define print(v) for(int i = 0; i < v.size(); i++) cout << v[i] << " "; cout<<endl;

void exploreCave(int N)
{
    int open[N];
    int ans[N];
    int used[N];

    for (int i = 0; i < N; i++)
    {
        open[i] = 0;
        used[i] = -1;
    }

    for (int i = 0; i < N; i++)
    {
        int l = 0;
        int r = N - 1;

        int pans = tryCombination(open);

        while (l < r)
        {
            int mid = (l + r) >> 1;

            for (int j = l; j <= mid; j++)
            {
                if (used[j] != -1) continue;

                open[j] = 1 - open[j];
            }

            int ans = tryCombination(open);

            for (int j = l; j <= mid; j++)
            {
                if (used[j] != -1) continue;

                open[j] = 1 - open[j];
            }

            if (pans == i)
            {
                if (ans != pans) r = mid;
                else l = mid + 1;
            }
            else
            {
                if (ans == pans) r = mid;
                else l = mid + 1;
            }
        }
        used[l] = i;

        if (pans == i) ans[l] = 1;
        else ans[l] = 0;
    }

    answer(ans, used);
}
#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...