Submission #1080307

# Submission time Handle Problem Language Result Execution time Memory
1080307 2024-08-29T08:45:24 Z Mihailo Cave (IOI13_cave) C++17
0 / 100
172 ms 592 KB
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;

int tryCombination(int S[]);

void answer(int S[],int D[]);

int correct[10000], query[10000], rez[10000], cur;
vector<int> unknown;

int find_switch(int door, int l, int r) {
    if(l==r) {
        correct[unknown[l]]=cur;
        return l;
    }
    for(int i=0; i<unknown.size()-1; i++) query[unknown[i]]=1-cur;
    int m=(l+r)/2;
    for(int i=l; i<=m; i++) query[unknown[i]]=cur;
    if(tryCombination(query)==door) return find_switch(door, m+1, r);
    else return find_switch(door, l, m);
}

void exploreCave(int N) {
    for(int i=N-1; i>=0; i--) unknown.push_back(i);
    for(int i=0; i<N; i++) {
        for(int j=0; j<unknown.size(); j++) query[unknown[j]]=0;
        if(tryCombination(query)==i) cur=1;
        else cur=0;
        int x=find_switch(i, 0, unknown.size()-1);
        rez[unknown[x]]=i;
        query[unknown[x]]=correct[unknown[x]];
        unknown.erase(unknown.begin()+x);
    }
    answer(correct, rez);
}

Compilation message

cave.cpp: In function 'int find_switch(int, int, int)':
cave.cpp:17:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i=0; i<unknown.size()-1; i++) query[unknown[i]]=1-cur;
      |                  ~^~~~~~~~~~~~~~~~~
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:27:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         for(int j=0; j<unknown.size(); j++) query[unknown[j]]=0;
      |                      ~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 105 ms 564 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 172 ms 592 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 105 ms 564 KB Answer is wrong
2 Halted 0 ms 0 KB -