Submission #878913

#TimeUsernameProblemLanguageResultExecution timeMemory
878913raul2008487Cave (IOI13_cave)C++17
0 / 100
2 ms348 KiB
#include <bits/stdc++.h>
#include "cave.h"
#define ll int
#define pb push_back
#define eb emplace_back
#define vl vector<ll>
#define fi first
#define se second
#define in insert
#define mpr make_pair
#define lg(x) __lg(x)
#define bpc(x) __builtin_popcount(x)
#define all(v) v.begin(), v.end()
#define endl "\n"
 
using namespace std;
const int sz = 5005;
void exploreCave(int N) {
    ll n, i, j, low, high, mid, a1, a2;
    ll ans1[n], ans2[n];
    for(i=0;i<n;i++){
        ans1[i] = 0;
		ans2[i] = -1;
    }
    for(i=0;i<n;i++){
        a1 = tryCombination(ans1);
        low = 0, high = n-1;
        while(low < high){
            mid = (low + high)>>1;
            for(j=low;j<=mid;j++){
                if(ans2[j] != -1){continue;}
                ans1[j] = (1 - ans1[j]);
            }
            a2 = tryCombination(ans1);
            for(j=low;j<=mid;j++){
                if(ans2[j] != -1){continue;}
                ans1[j] = (1 - ans1[j]);
            }
            if(a1 == -1){
                if(a2 == i){high = mid;}
                else{
                    low = mid + 1;
                }
            }
            else if(a1 == i){
                if(a2 != a1 || a2 == -1){ /// *
                    high = mid;
                }
                else{
                    low = mid + 1;
                }
            }
            else{
                if(a2 == i){
                    high = mid;
                }
                else{
                    low = mid + 1;
                }
            }
       }
       ans2[low] = i;
       if(a1 == i){
        ans1[low] = 1;
       }
       else{
        ans1[low] = 0;
       }
       //ans1[low] = (a1 == i);
    }
    answer(ans1, ans2);
}

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:20:14: warning: 'n' is used uninitialized in this function [-Wuninitialized]
   20 |     ll ans1[n], ans2[n];
      |              ^
#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...