Submission #1320169

#TimeUsernameProblemLanguageResultExecution timeMemory
1320169yessimkhanCave (IOI13_cave)C++20
34 / 100
7 ms524 KiB
#include "cave.h"
#include <bits/stdc++.h>
// solved by bekagg
#define ll long long
#define ent '\n'
#define pb push_back
#define all(x) x.begin(),x.end()
#define PRaim_bek_abi ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;

const int N = 5e5+5;
const int MOD = 1e9+7;

int d[N] , cnt , us[N] , s[N];

void exploreCave(int n){
    bool t = 1;
    while(cnt < n){
        t = 1 - t;

        for (int i = 0; i < n; i++){
            if (us[i]) continue;
            s[i] = t;
        }

        int p = tryCombination(s);

        if (p == -1){
            for (int i = 0; i < n; i++){
                if (us[i]) continue;
                s[i] = 1 - t;
                int pos = tryCombination(s);
                s[i] = t;
                d[i] = pos;
                us[i] = 1;
                cnt++;
            }
            break;
        }

        for (int i = 0; i < n; i++){
            if (us[i]) continue;
            s[i] = 1 - t;
            int pos = tryCombination(s);
            if (pos != -1 and pos < p){
                d[i] = pos;
                us[i] = 1;
                cnt++;
            }
            s[i] = t;
        }

    }

    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...