Submission #783976

#TimeUsernameProblemLanguageResultExecution timeMemory
783976BoasCave (IOI13_cave)C++17
46 / 100
11 ms452 KiB
#include <bits/stdc++.h> #include "cave.h" using namespace std; constexpr bool debug = false; typedef vector<int> vi; // map<vi, int> tryCombi; int ownTryCombination(vi &switches) { if (debug) { cerr << endl << "TryCombination: "; for (int t : switches) { cerr << t << " "; } cerr << endl; } int res; // if (tryCombi.find(switches) != tryCombi.end()) //{ // res = tryCombi[switches]; //} // else { res = tryCombination(switches.data()); // tryCombi[switches] = res; } if (debug) cerr << "Result: " << res << endl; return res; } void exploreCave(int N) { vi switches(N, 0); vi minDist(N); vi maxDist(N, N); int d = ownTryCombination(switches); int nd = 0; while (d != -1) { if (nd == -1) break; for (int i = 0; i < N; i++) { if (minDist[i] == maxDist[i]) continue; switches[i] = !switches[i]; nd = ownTryCombination(switches); if (nd == -1) break; if (nd == d) { if (debug) cerr << "minDist[" << i << "] = " << d + 1 << endl; minDist[i] = d + 1; switches[i] = !switches[i]; d = nd; } else if (nd > d) { if (debug) cerr << "min&maxDist[" << i << "] = " << d << endl; minDist[i] = d; maxDist[i] = d; d = nd; } else { if (debug) cerr << "min&maxDist[" << i << "] = " << nd << endl; minDist[i] = nd; maxDist[i] = nd; switches[i] = !switches[i]; // i--; } } if (nd == -1) break; } for (int i = 0; i < N; i++) { if (minDist[i] == maxDist[i]) continue; switches[i] = !switches[i]; int d = ownTryCombination(switches); minDist[i] = d; maxDist[i] = d; switches[i] = !switches[i]; } answer(switches.data(), minDist.data()); cerr << endl; }
#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...