Submission #805278

# Submission time Handle Problem Language Result Execution time Memory
805278 2023-08-03T14:44:05 Z ma_moutahid Cave (IOI13_cave) C++17
0 / 100
113 ms 648 KB
#include <bits/stdc++.h>
#include "cave.h"
using ll =long long;
ll LINF=1000000000000000000;
int INF=1000000000;
#define pi pair<int,int>
#define pl pair<ll,ll>
#define endl '\n'
#define vi vector<int>
#define vii vector<vector<int>>
#define vl vector<ll>
#define vll vector<vector<ll>>
//#define int ll
using namespace std;

vi correct;
int n;
void sett(int *v,int l,int r,int pos){
    for(int i=0;i<l;i++){
        v[i]=!pos;
    }
    for(int i=r+1;i<n;i++)v[i]=!pos;
    for(int i=l;i<=r;i++)v[i]=pos;
}

void exploreCave(int N) {
    correct.resize(N,-1);
    n=N;
    int combination[N];
    for(int i=0;i<N;i++)combination[i]=0;
    int found=0;
    int cave=0;
    int location[N];
    int t;
    t=tryCombination(combination);
    for(int i=0;i<t;i++)correct[i]=0;
    correct[t]=1;
    while (1){
        int l=0,r=N-1;
        while(l!=r){
            int m=(l+r)/2;
            sett(combination,m+1,r,correct[cave]);
            t=tryCombination(combination);
            if(t==-1){
                answer(combination,location);
                return;
            }
            if(t>cave)l=m+1;
            else r=m;
        }
        location[cave]=l;
        for(int i=cave;i<t;i++)correct[i]=combination[i];
        correct[t]=!combination[t];
        cave++;
    }

}


Compilation message

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:31:9: warning: unused variable 'found' [-Wunused-variable]
   31 |     int found=0;
      |         ^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 93 ms 380 KB too much calls on tryCombination()
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 113 ms 648 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 42 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 42 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 93 ms 380 KB too much calls on tryCombination()
2 Halted 0 ms 0 KB -