Submission #467542

#TimeUsernameProblemLanguageResultExecution timeMemory
467542lordlorincCave (IOI13_cave)C++17
100 / 100
397 ms452 KiB
#include <bits/stdc++.h> #include "cave.h" using namespace std; // int main(){ // return 0; // } void exploreCave(int n) { int swiches[n], partners[n]; bool founded[n]; swiches[0] = 1; swiches[1] = 1; swiches[2] = 1; swiches[3] = 1; //cout << tryCombination(swiches) << " wdsvlkn" << endl; fill(founded, founded + n, false); fill(partners, partners + n, -1); for (int i = 0; i < n; i++) { int l = 0, r = n - 1; for (int j = 0; j < n; j++) { if (founded[j] == false) { swiches[j] = 0; } } //cout << tryCombination(swiches) << endl; int subThing = tryCombination(swiches); int status = subThing <= i && subThing != -1; //cout << status << endl; while (l != r){ int mid = (l + r) / 2; for (int j = l; j <= r; j++) { if (founded[j] == true) continue; if (j <= mid){ swiches[j] = status; } else{ swiches[j] = 1 - status; } } //for (int i = 0; i < n; i++) cout << swiches[i] << " "; //cout << endl; int comb = tryCombination(swiches); //cout << comb << endl; if (comb <= i && comb != -1){ l = mid + 1; } else r = mid; } //cout << l << endl; swiches[l] = status; //cout << endl; founded[l] = true; partners[l] = i; } answer(swiches, partners); }
#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...