Submission #415650

#TimeUsernameProblemLanguageResultExecution timeMemory
415650JediMaster11Cave (IOI13_cave)C++17
0 / 100
3 ms720 KiB
#include <bits/stdc++.h> #include "cave.h" using namespace std; #define fo(i, a, b) for (int i = a; i < (int)b; i++) // int tryCombination(int S[]) // { // int ret = -1; // int ans[] = {1, 1, 1, 0}; // int pos[] = {3, 1, 0, 2}; // int count = 0; // bool end = false; // while (count < 4 && !end) // { // fo(i, 0, 4) // { // if (pos[i] == count) // { // if (ans[i] != S[i]) // { // ret = pos[i]; // end = true; // } // break; // } // } // count++; // } // return ret; // } // void answer(int S[], int D[]) // { // S is the order of flicked levers, D is the number of the levers // int size = 4; // fo(i, 0, size) // { // cout << S[i] << " " << D[i] << endl; // } // } void exploreCave(int n) { // n - number of levers int order[n]; int correct[n]; int guess[n]; int count = 0; fo(i, 0, n) { order[i] = -1; correct[i] = 0; guess[i] = 0; } int on = 0; int g1 = tryCombination(guess); int g2; bool foundCorrect = false; while (count < n) { if (!foundCorrect) { guess[on] = guess[on] == 1 ? 0 : 1; g2 = tryCombination(guess); if (g2 == -1) { foundCorrect = true; fo(i, 0, n) { correct[i] = guess[i]; } order[on] = g1; count++; on = 0; } else { if (g1 != g2) { if (g1 < g2) { order[on] = g1; correct[on] = guess[on]; count++; } else { order[on] = g2; correct[on] = guess[on] == 1 ? 0 : 1; count++; } } on++; g1 = g2; } } else { while (order[on] != -1) // on < count && { on++; } guess[on] = guess[on] == 1 ? 0 : 1; g2 = tryCombination(guess); guess[on] = guess[on] == 1 ? 0 : 1; order[on] = g2; count++; } //when the answer we get back is -1, we know we have 'correct', so then we just go by one by one, to get which ever operrates which switch } answer(correct, order); } // int main() // { // ios::sync_with_stdio(0); // cin.tie(0); // exploreCave(4); // }
#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...