Submission #1310700

#TimeUsernameProblemLanguageResultExecution timeMemory
1310700putuputuCave (IOI13_cave)C++20
0 / 100
145 ms600 KiB
#include "cave.h"
#include<bits/stdc++.h>
using namespace std;
void exploreCave(int n) {
    auto norm = [&](int x) -> int {
        if (x == -1 || x == 0) return -1;
        return x - 1;
    };
    vector<int> s(n, 0);
    vector<int> use(n, 0);
    vector<int> dswitch(n, -1);
    vector<int> state(n, 0);
    for(int i=0; i<n; i++){
        vector<int>c;
        for(int j=0; j<n; j++){
            if(!use[j]){
                c.push_back(j);
            }
        }
        fill(s.begin(), s.end(), 0);
        for(int j=0; j<i; j++){
            s[dswitch[j]]=state[j];
        }
        int base=norm(tryCombination(s.data()));
        bool doorOpen=(base==-1 or base>i);
        if(doorOpen){
            for(int x : c){
                s[x]=1;
            }
        }
        int l=0, r=(int)c.size()-1;
        int find=-1;
        while(l<=r){
            int m=(l+r)/2;
            vector<int> s2=s;
            for(int j=l; j<=m; j++){
                s2[c[j]]^=1;
            }
            int res=norm(tryCombination(s2.data()));
            if(res==-1 or res>i){
                find=c[m];
                r=m-1;
            }else{
                l=m+1;
            }
        }
        if(find==-1){
            return;
        }
        vector<int> s3=s;
        s3[find]^=1;
        int res2=norm(tryCombination(s3.data()));
        int need;
        if(res2==-1 or res2>i){
            need=s3[find];
        }else{
            need=s[find];
        }
        use[find]=1;
        dswitch[i]=find;
        state[i]=need;
    }
    answer(dswitch.data(), state.data());
}
#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...